mdp4_format.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Copyright (C) 2013 Red Hat
  3. * Author: Rob Clark <robdclark@gmail.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License version 2 as published by
  7. * the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #include "msm_drv.h"
  18. #include "mdp4_kms.h"
  19. #define FMT(name, a, r, g, b, e0, e1, e2, e3, alpha, tight, c, cnt) { \
  20. .base = { .pixel_format = DRM_FORMAT_ ## name }, \
  21. .bpc_a = BPC ## a ## A, \
  22. .bpc_r = BPC ## r, \
  23. .bpc_g = BPC ## g, \
  24. .bpc_b = BPC ## b, \
  25. .unpack = { e0, e1, e2, e3 }, \
  26. .alpha_enable = alpha, \
  27. .unpack_tight = tight, \
  28. .cpp = c, \
  29. .unpack_count = cnt, \
  30. }
  31. #define BPC0A 0
  32. static const struct mdp4_format formats[] = {
  33. /* name a r g b e0 e1 e2 e3 alpha tight cpp cnt */
  34. FMT(ARGB8888, 8, 8, 8, 8, 1, 0, 2, 3, true, true, 4, 4),
  35. FMT(XRGB8888, 8, 8, 8, 8, 1, 0, 2, 3, false, true, 4, 4),
  36. FMT(RGB888, 0, 8, 8, 8, 1, 0, 2, 0, false, true, 3, 3),
  37. FMT(BGR888, 0, 8, 8, 8, 2, 0, 1, 0, false, true, 3, 3),
  38. FMT(RGB565, 0, 5, 6, 5, 1, 0, 2, 0, false, true, 2, 3),
  39. FMT(BGR565, 0, 5, 6, 5, 2, 0, 1, 0, false, true, 2, 3),
  40. };
  41. uint32_t mdp4_get_formats(enum mdp4_pipe pipe_id, uint32_t *pixel_formats,
  42. uint32_t max_formats)
  43. {
  44. uint32_t i;
  45. for (i = 0; i < ARRAY_SIZE(formats); i++) {
  46. const struct mdp4_format *f = &formats[i];
  47. if (i == max_formats)
  48. break;
  49. pixel_formats[i] = f->base.pixel_format;
  50. }
  51. return i;
  52. }
  53. const struct msm_format *mdp4_get_format(struct msm_kms *kms, uint32_t format)
  54. {
  55. int i;
  56. for (i = 0; i < ARRAY_SIZE(formats); i++) {
  57. const struct mdp4_format *f = &formats[i];
  58. if (f->base.pixel_format == format)
  59. return &f->base;
  60. }
  61. return NULL;
  62. }