Skip to content

Commit e092514

Browse files
committed
drm/msm: convert msm_format::unpack_tight to the flag
Instead of having a u8 or bool field unpack_tight, convert it to the flag, this save space in the tables and allows us to handle all booleans in the same way. Reviewed-by: Abhinav Kumar <[email protected]> Signed-off-by: Dmitry Baryshkov <[email protected]> Patchwork: https://patchwork.freedesktop.org/patch/590428/ Link: https://lore.kernel.org/r/[email protected]
1 parent 0e67f51 commit e092514

File tree

7 files changed

+41
-47
lines changed

7 files changed

+41
-47
lines changed

drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,10 @@ bp, flg, fm, np) \
4444
.bpc_a = a, \
4545
.chroma_sample = CHROMA_FULL, \
4646
.unpack_align_msb = 0, \
47-
.unpack_tight = 1, \
4847
.unpack_count = uc, \
4948
.bpp = bp, \
5049
.fetch_mode = fm, \
51-
.flags = flg, \
50+
.flags = MSM_FORMAT_FLAG_UNPACK_TIGHT | flg, \
5251
.num_planes = np, \
5352
.tile_height = DPU_TILE_HEIGHT_DEFAULT \
5453
}
@@ -66,11 +65,10 @@ alpha, bp, flg, fm, np, th) \
6665
.bpc_a = a, \
6766
.chroma_sample = CHROMA_FULL, \
6867
.unpack_align_msb = 0, \
69-
.unpack_tight = 1, \
7068
.unpack_count = uc, \
7169
.bpp = bp, \
7270
.fetch_mode = fm, \
73-
.flags = flg, \
71+
.flags = MSM_FORMAT_FLAG_UNPACK_TIGHT | flg, \
7472
.num_planes = np, \
7573
.tile_height = th \
7674
}
@@ -89,11 +87,10 @@ alpha, chroma, count, bp, flg, fm, np) \
8987
.bpc_a = a, \
9088
.chroma_sample = chroma, \
9189
.unpack_align_msb = 0, \
92-
.unpack_tight = 1, \
9390
.unpack_count = count, \
9491
.bpp = bp, \
9592
.fetch_mode = fm, \
96-
.flags = flg, \
93+
.flags = MSM_FORMAT_FLAG_UNPACK_TIGHT | flg, \
9794
.num_planes = np, \
9895
.tile_height = DPU_TILE_HEIGHT_DEFAULT \
9996
}
@@ -110,11 +107,10 @@ alpha, chroma, count, bp, flg, fm, np) \
110107
.bpc_a = a, \
111108
.chroma_sample = chroma, \
112109
.unpack_align_msb = 0, \
113-
.unpack_tight = 1, \
114110
.unpack_count = 2, \
115111
.bpp = 2, \
116112
.fetch_mode = fm, \
117-
.flags = flg, \
113+
.flags = MSM_FORMAT_FLAG_UNPACK_TIGHT | flg, \
118114
.num_planes = np, \
119115
.tile_height = DPU_TILE_HEIGHT_DEFAULT \
120116
}
@@ -132,11 +128,10 @@ flg, fm, np, th) \
132128
.bpc_a = a, \
133129
.chroma_sample = chroma, \
134130
.unpack_align_msb = 0, \
135-
.unpack_tight = 1, \
136131
.unpack_count = 2, \
137132
.bpp = 2, \
138133
.fetch_mode = fm, \
139-
.flags = flg, \
134+
.flags = MSM_FORMAT_FLAG_UNPACK_TIGHT | flg, \
140135
.num_planes = np, \
141136
.tile_height = th \
142137
}
@@ -153,7 +148,6 @@ flg, fm, np, th) \
153148
.bpc_a = a, \
154149
.chroma_sample = chroma, \
155150
.unpack_align_msb = 1, \
156-
.unpack_tight = 0, \
157151
.unpack_count = 2, \
158152
.bpp = 2, \
159153
.fetch_mode = fm, \
@@ -175,7 +169,6 @@ flg, fm, np, th) \
175169
.bpc_a = a, \
176170
.chroma_sample = chroma, \
177171
.unpack_align_msb = 1, \
178-
.unpack_tight = 0, \
179172
.unpack_count = 2, \
180173
.bpp = 2, \
181174
.fetch_mode = fm, \
@@ -198,11 +191,10 @@ flg, fm, np) \
198191
.bpc_a = a, \
199192
.chroma_sample = chroma, \
200193
.unpack_align_msb = 0, \
201-
.unpack_tight = 1, \
202194
.unpack_count = 1, \
203195
.bpp = bp, \
204196
.fetch_mode = fm, \
205-
.flags = flg, \
197+
.flags = MSM_FORMAT_FLAG_UNPACK_TIGHT | flg, \
206198
.num_planes = np, \
207199
.tile_height = DPU_TILE_HEIGHT_DEFAULT \
208200
}
@@ -636,7 +628,7 @@ static int _dpu_format_get_media_color_ubwc(const struct msm_format *fmt)
636628
if (fmt->pixel_format == DRM_FORMAT_NV12 ||
637629
fmt->pixel_format == DRM_FORMAT_P010) {
638630
if (MSM_FORMAT_IS_DX(fmt)) {
639-
if (fmt->unpack_tight)
631+
if (fmt->flags & MSM_FORMAT_FLAG_UNPACK_TIGHT)
640632
color_fmt = COLOR_FMT_NV12_BPP10_UBWC;
641633
else
642634
color_fmt = COLOR_FMT_P010_UBWC;

drivers/gpu/drm/msm/disp/dpu1/dpu_hw_sspp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ static void dpu_hw_sspp_setup_format(struct dpu_sw_pipe *pipe,
263263
unpack = (fmt->element[3] << 24) | (fmt->element[2] << 16) |
264264
(fmt->element[1] << 8) | (fmt->element[0] << 0);
265265
src_format |= ((fmt->unpack_count - 1) << 12) |
266-
(fmt->unpack_tight << 17) |
266+
((fmt->flags & MSM_FORMAT_FLAG_UNPACK_TIGHT ? 1 : 0) << 17) |
267267
(fmt->unpack_align_msb << 18) |
268268
((fmt->bpp - 1) << 9);
269269

drivers/gpu/drm/msm/disp/dpu1/dpu_hw_wb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static void dpu_hw_wb_setup_format(struct dpu_hw_wb *ctx,
9898
(fmt->element[0] << 0);
9999

100100
dst_format |= (fmt->unpack_align_msb << 18) |
101-
(fmt->unpack_tight << 17) |
101+
((fmt->flags & MSM_FORMAT_FLAG_UNPACK_TIGHT ? 1 : 0) << 17) |
102102
((fmt->unpack_count - 1) << 12) |
103103
((fmt->bpp - 1) << 9);
104104

drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,8 @@ static int mdp4_plane_mode_set(struct drm_plane *plane,
325325
MDP4_PIPE_SRC_FORMAT_FETCH_PLANES(format->fetch_type) |
326326
MDP4_PIPE_SRC_FORMAT_CHROMA_SAMP(format->chroma_sample) |
327327
MDP4_PIPE_SRC_FORMAT_FRAME_FORMAT(frame_type) |
328-
COND(format->unpack_tight, MDP4_PIPE_SRC_FORMAT_UNPACK_TIGHT));
328+
COND(format->flags & MSM_FORMAT_FLAG_UNPACK_TIGHT,
329+
MDP4_PIPE_SRC_FORMAT_UNPACK_TIGHT));
329330

330331
mdp4_write(mdp4_kms, REG_MDP4_PIPE_SRC_UNPACK(pipe),
331332
MDP4_PIPE_SRC_UNPACK_ELEM0(format->element[0]) |

drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,8 @@ static void mdp5_hwpipe_mode_set(struct mdp5_kms *mdp5_kms,
801801
COND(format->alpha_enable, MDP5_PIPE_SRC_FORMAT_ALPHA_ENABLE) |
802802
MDP5_PIPE_SRC_FORMAT_CPP(format->bpp - 1) |
803803
MDP5_PIPE_SRC_FORMAT_UNPACK_COUNT(format->unpack_count - 1) |
804-
COND(format->unpack_tight, MDP5_PIPE_SRC_FORMAT_UNPACK_TIGHT) |
804+
COND(format->flags & MSM_FORMAT_FLAG_UNPACK_TIGHT,
805+
MDP5_PIPE_SRC_FORMAT_UNPACK_TIGHT) |
805806
MDP5_PIPE_SRC_FORMAT_FETCH_TYPE(format->fetch_type) |
806807
MDP5_PIPE_SRC_FORMAT_CHROMA_SAMP(format->chroma_sample));
807808

drivers/gpu/drm/msm/disp/mdp_format.c

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static struct csc_cfg csc_convert[CSC_MAX] = {
6262
},
6363
};
6464

65-
#define FMT(name, a, r, g, b, e0, e1, e2, e3, alpha, tight, c, cnt, fp, cs, yuv) { \
65+
#define FMT(name, a, r, g, b, e0, e1, e2, e3, alpha, c, cnt, fp, cs, yuv) { \
6666
.pixel_format = DRM_FORMAT_ ## name, \
6767
.bpc_a = BPC ## a ## A, \
6868
.bpc_r_cr = BPC ## r, \
@@ -72,65 +72,65 @@ static struct csc_cfg csc_convert[CSC_MAX] = {
7272
.fetch_type = fp, \
7373
.chroma_sample = cs, \
7474
.alpha_enable = alpha, \
75-
.unpack_tight = tight, \
7675
.unpack_count = cnt, \
7776
.bpp = c, \
78-
.flags = yuv ? MSM_FORMAT_FLAG_YUV : 0, \
77+
.flags = MSM_FORMAT_FLAG_UNPACK_TIGHT | \
78+
(yuv ? MSM_FORMAT_FLAG_YUV : 0), \
7979
}
8080

8181
#define BPC0A 0
8282

8383
static const struct msm_format formats[] = {
84-
/* name a r g b e0 e1 e2 e3 alpha tight cpp cnt ... */
85-
FMT(ARGB8888, 8, 8, 8, 8, 1, 0, 2, 3, true, true, 4, 4,
84+
/* name a r g b e0 e1 e2 e3 alpha cpp cnt ... */
85+
FMT(ARGB8888, 8, 8, 8, 8, 1, 0, 2, 3, true, 4, 4,
8686
MDP_PLANE_INTERLEAVED, CHROMA_FULL, false),
87-
FMT(ABGR8888, 8, 8, 8, 8, 2, 0, 1, 3, true, true, 4, 4,
87+
FMT(ABGR8888, 8, 8, 8, 8, 2, 0, 1, 3, true, 4, 4,
8888
MDP_PLANE_INTERLEAVED, CHROMA_FULL, false),
89-
FMT(RGBA8888, 8, 8, 8, 8, 3, 1, 0, 2, true, true, 4, 4,
89+
FMT(RGBA8888, 8, 8, 8, 8, 3, 1, 0, 2, true, 4, 4,
9090
MDP_PLANE_INTERLEAVED, CHROMA_FULL, false),
91-
FMT(BGRA8888, 8, 8, 8, 8, 3, 2, 0, 1, true, true, 4, 4,
91+
FMT(BGRA8888, 8, 8, 8, 8, 3, 2, 0, 1, true, 4, 4,
9292
MDP_PLANE_INTERLEAVED, CHROMA_FULL, false),
93-
FMT(XRGB8888, 8, 8, 8, 8, 1, 0, 2, 3, false, true, 4, 4,
93+
FMT(XRGB8888, 8, 8, 8, 8, 1, 0, 2, 3, false, 4, 4,
9494
MDP_PLANE_INTERLEAVED, CHROMA_FULL, false),
95-
FMT(XBGR8888, 8, 8, 8, 8, 2, 0, 1, 3, false, true, 4, 4,
95+
FMT(XBGR8888, 8, 8, 8, 8, 2, 0, 1, 3, false, 4, 4,
9696
MDP_PLANE_INTERLEAVED, CHROMA_FULL, false),
97-
FMT(RGBX8888, 8, 8, 8, 8, 3, 1, 0, 2, false, true, 4, 4,
97+
FMT(RGBX8888, 8, 8, 8, 8, 3, 1, 0, 2, false, 4, 4,
9898
MDP_PLANE_INTERLEAVED, CHROMA_FULL, false),
99-
FMT(BGRX8888, 8, 8, 8, 8, 3, 2, 0, 1, false, true, 4, 4,
99+
FMT(BGRX8888, 8, 8, 8, 8, 3, 2, 0, 1, false, 4, 4,
100100
MDP_PLANE_INTERLEAVED, CHROMA_FULL, false),
101-
FMT(RGB888, 0, 8, 8, 8, 1, 0, 2, 0, false, true, 3, 3,
101+
FMT(RGB888, 0, 8, 8, 8, 1, 0, 2, 0, false, 3, 3,
102102
MDP_PLANE_INTERLEAVED, CHROMA_FULL, false),
103-
FMT(BGR888, 0, 8, 8, 8, 2, 0, 1, 0, false, true, 3, 3,
103+
FMT(BGR888, 0, 8, 8, 8, 2, 0, 1, 0, false, 3, 3,
104104
MDP_PLANE_INTERLEAVED, CHROMA_FULL, false),
105-
FMT(RGB565, 0, 5, 6, 5, 1, 0, 2, 0, false, true, 2, 3,
105+
FMT(RGB565, 0, 5, 6, 5, 1, 0, 2, 0, false, 2, 3,
106106
MDP_PLANE_INTERLEAVED, CHROMA_FULL, false),
107-
FMT(BGR565, 0, 5, 6, 5, 2, 0, 1, 0, false, true, 2, 3,
107+
FMT(BGR565, 0, 5, 6, 5, 2, 0, 1, 0, false, 2, 3,
108108
MDP_PLANE_INTERLEAVED, CHROMA_FULL, false),
109109

110110
/* --- RGB formats above / YUV formats below this line --- */
111111

112112
/* 2 plane YUV */
113-
FMT(NV12, 0, 8, 8, 8, 1, 2, 0, 0, false, true, 2, 2,
113+
FMT(NV12, 0, 8, 8, 8, 1, 2, 0, 0, false, 2, 2,
114114
MDP_PLANE_PSEUDO_PLANAR, CHROMA_420, true),
115-
FMT(NV21, 0, 8, 8, 8, 2, 1, 0, 0, false, true, 2, 2,
115+
FMT(NV21, 0, 8, 8, 8, 2, 1, 0, 0, false, 2, 2,
116116
MDP_PLANE_PSEUDO_PLANAR, CHROMA_420, true),
117-
FMT(NV16, 0, 8, 8, 8, 1, 2, 0, 0, false, true, 2, 2,
117+
FMT(NV16, 0, 8, 8, 8, 1, 2, 0, 0, false, 2, 2,
118118
MDP_PLANE_PSEUDO_PLANAR, CHROMA_H2V1, true),
119-
FMT(NV61, 0, 8, 8, 8, 2, 1, 0, 0, false, true, 2, 2,
119+
FMT(NV61, 0, 8, 8, 8, 2, 1, 0, 0, false, 2, 2,
120120
MDP_PLANE_PSEUDO_PLANAR, CHROMA_H2V1, true),
121121
/* 1 plane YUV */
122-
FMT(VYUY, 0, 8, 8, 8, 2, 0, 1, 0, false, true, 2, 4,
122+
FMT(VYUY, 0, 8, 8, 8, 2, 0, 1, 0, false, 2, 4,
123123
MDP_PLANE_INTERLEAVED, CHROMA_H2V1, true),
124-
FMT(UYVY, 0, 8, 8, 8, 1, 0, 2, 0, false, true, 2, 4,
124+
FMT(UYVY, 0, 8, 8, 8, 1, 0, 2, 0, false, 2, 4,
125125
MDP_PLANE_INTERLEAVED, CHROMA_H2V1, true),
126-
FMT(YUYV, 0, 8, 8, 8, 0, 1, 0, 2, false, true, 2, 4,
126+
FMT(YUYV, 0, 8, 8, 8, 0, 1, 0, 2, false, 2, 4,
127127
MDP_PLANE_INTERLEAVED, CHROMA_H2V1, true),
128-
FMT(YVYU, 0, 8, 8, 8, 0, 2, 0, 1, false, true, 2, 4,
128+
FMT(YVYU, 0, 8, 8, 8, 0, 2, 0, 1, false, 2, 4,
129129
MDP_PLANE_INTERLEAVED, CHROMA_H2V1, true),
130130
/* 3 plane YUV */
131-
FMT(YUV420, 0, 8, 8, 8, 2, 1, 0, 0, false, true, 1, 1,
131+
FMT(YUV420, 0, 8, 8, 8, 2, 1, 0, 0, false, 1, 1,
132132
MDP_PLANE_PLANAR, CHROMA_420, true),
133-
FMT(YVU420, 0, 8, 8, 8, 1, 2, 0, 0, false, true, 1, 1,
133+
FMT(YVU420, 0, 8, 8, 8, 1, 2, 0, 0, false, 1, 1,
134134
MDP_PLANE_PLANAR, CHROMA_420, true),
135135
};
136136

drivers/gpu/drm/msm/disp/mdp_format.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ enum msm_format_flags {
1414
MSM_FORMAT_FLAG_YUV_BIT,
1515
MSM_FORMAT_FLAG_DX_BIT,
1616
MSM_FORMAT_FLAG_COMPRESSED_BIT,
17+
MSM_FORMAT_FLAG_UNPACK_TIGHT_BIT,
1718
};
1819

1920
#define MSM_FORMAT_FLAG_YUV BIT(MSM_FORMAT_FLAG_YUV_BIT)
2021
#define MSM_FORMAT_FLAG_DX BIT(MSM_FORMAT_FLAG_DX_BIT)
2122
#define MSM_FORMAT_FLAG_COMPRESSED BIT(MSM_FORMAT_FLAG_COMPRESSED_BIT)
23+
#define MSM_FORMAT_FLAG_UNPACK_TIGHT BIT(MSM_FORMAT_FLAG_UNPACK_TIGHT_BIT)
2224

2325
/**
2426
* struct msm_format: defines the format configuration
@@ -27,7 +29,6 @@ enum msm_format_flags {
2729
* @fetch_type: how the color components are packed in pixel format
2830
* @chroma_sample: chroma sub-samplng type
2931
* @alpha_enable: whether the format has an alpha channel
30-
* @unpack_tight: whether to use tight or loose unpack
3132
* @unpack_align_msb: unpack aligned to LSB or MSB
3233
* @unpack_count: number of the components to unpack
3334
* @bpp: bytes per pixel
@@ -44,7 +45,6 @@ struct msm_format {
4445
enum mdp_fetch_type fetch_type;
4546
enum mdp_chroma_samp_type chroma_sample;
4647
bool alpha_enable;
47-
u8 unpack_tight;
4848
u8 unpack_align_msb;
4949
u8 unpack_count;
5050
u8 bpp;

0 commit comments

Comments
 (0)