drm/msm: update generated headers
[linux-2.6-block.git] / drivers / gpu / drm / msm / mdp / mdp_format.c
CommitLineData
c8afe684
RC
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
18
19#include "msm_drv.h"
10a02eb6 20#include "mdp_kms.h"
c8afe684
RC
21
22#define FMT(name, a, r, g, b, e0, e1, e2, e3, alpha, tight, c, cnt) { \
23 .base = { .pixel_format = DRM_FORMAT_ ## name }, \
24 .bpc_a = BPC ## a ## A, \
25 .bpc_r = BPC ## r, \
26 .bpc_g = BPC ## g, \
27 .bpc_b = BPC ## b, \
28 .unpack = { e0, e1, e2, e3 }, \
29 .alpha_enable = alpha, \
30 .unpack_tight = tight, \
31 .cpp = c, \
32 .unpack_count = cnt, \
33 }
34
35#define BPC0A 0
36
10a02eb6 37static const struct mdp_format formats[] = {
c8afe684
RC
38 /* name a r g b e0 e1 e2 e3 alpha tight cpp cnt */
39 FMT(ARGB8888, 8, 8, 8, 8, 1, 0, 2, 3, true, true, 4, 4),
40 FMT(XRGB8888, 8, 8, 8, 8, 1, 0, 2, 3, false, true, 4, 4),
41 FMT(RGB888, 0, 8, 8, 8, 1, 0, 2, 0, false, true, 3, 3),
42 FMT(BGR888, 0, 8, 8, 8, 2, 0, 1, 0, false, true, 3, 3),
43 FMT(RGB565, 0, 5, 6, 5, 1, 0, 2, 0, false, true, 2, 3),
44 FMT(BGR565, 0, 5, 6, 5, 2, 0, 1, 0, false, true, 2, 3),
45};
46
10a02eb6 47uint32_t mdp_get_formats(uint32_t *pixel_formats, uint32_t max_formats)
a8623918
RC
48{
49 uint32_t i;
50 for (i = 0; i < ARRAY_SIZE(formats); i++) {
10a02eb6 51 const struct mdp_format *f = &formats[i];
a8623918
RC
52
53 if (i == max_formats)
54 break;
55
56 pixel_formats[i] = f->base.pixel_format;
57 }
58
59 return i;
60}
61
10a02eb6 62const struct msm_format *mdp_get_format(struct msm_kms *kms, uint32_t format)
c8afe684
RC
63{
64 int i;
65 for (i = 0; i < ARRAY_SIZE(formats); i++) {
10a02eb6 66 const struct mdp_format *f = &formats[i];
c8afe684
RC
67 if (f->base.pixel_format == format)
68 return &f->base;
69 }
70 return NULL;
71}