Skip to content

Commit 5b824f0

Browse files
6by9pelwell
authored andcommitted
drm/vc4: plane: Swap Cb/Cr pointers for YVU formats
hvs6 appears to have dropped support for the component order field in 3 plane YUV formats. Support them by swapping the Cb and Cr planes over when reading the image pointers. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
1 parent 60f7b3f commit 5b824f0

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

drivers/gpu/drm/vc4/vc4_plane.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ static const struct hvs_format {
3737
u32 pixel_order_hvs5;
3838
bool hvs5_only;
3939
bool hvs6_only;
40+
bool hvs6_swap_chroma_pointers;
4041
} hvs_formats[] = {
4142
{
4243
.drm = DRM_FORMAT_XRGB8888,
@@ -109,6 +110,7 @@ static const struct hvs_format {
109110
.hvs = HVS_PIXEL_FORMAT_YCBCR_YUV422_3PLANE,
110111
.pixel_order = HVS_PIXEL_ORDER_XYCRCB,
111112
.pixel_order_hvs5 = HVS_PIXEL_ORDER_XYCRCB,
113+
.hvs6_swap_chroma_pointers = true,
112114
},
113115
{
114116
.drm = DRM_FORMAT_YUV444,
@@ -121,6 +123,7 @@ static const struct hvs_format {
121123
.hvs = HVS_PIXEL_FORMAT_YCBCR_YUV422_3PLANE,
122124
.pixel_order = HVS_PIXEL_ORDER_XYCRCB,
123125
.pixel_order_hvs5 = HVS_PIXEL_ORDER_XYCRCB,
126+
.hvs6_swap_chroma_pointers = true,
124127
},
125128
{
126129
.drm = DRM_FORMAT_YUV420,
@@ -133,6 +136,7 @@ static const struct hvs_format {
133136
.hvs = HVS_PIXEL_FORMAT_YCBCR_YUV420_3PLANE,
134137
.pixel_order = HVS_PIXEL_ORDER_XYCRCB,
135138
.pixel_order_hvs5 = HVS_PIXEL_ORDER_XYCRCB,
139+
.hvs6_swap_chroma_pointers = true,
136140
},
137141
{
138142
.drm = DRM_FORMAT_NV12,
@@ -1873,6 +1877,14 @@ static u32 vc6_plane_get_csc_mode(struct vc4_plane_state *vc4_state)
18731877
return ret;
18741878
}
18751879

1880+
static int vc6_get_plane_idx(const struct hvs_format *format, int plane)
1881+
{
1882+
if (!plane || !format->hvs6_swap_chroma_pointers)
1883+
return plane;
1884+
1885+
return (plane == 1) ? 2 : 1;
1886+
}
1887+
18761888
static int vc6_plane_mode_set(struct drm_plane *plane,
18771889
struct drm_plane_state *state)
18781890
{
@@ -2165,8 +2177,10 @@ static int vc6_plane_mode_set(struct drm_plane *plane,
21652177
* TODO: This only covers Raster Scan Order planes
21662178
*/
21672179
for (i = 0; i < num_planes; i++) {
2168-
struct drm_gem_dma_object *bo = drm_fb_dma_get_gem_obj(fb, i);
2169-
dma_addr_t paddr = bo->dma_addr + fb->offsets[i] + offsets[i];
2180+
int idx = vc6_get_plane_idx(format, i);
2181+
struct drm_gem_dma_object *bo =
2182+
drm_fb_dma_get_gem_obj(fb, idx);
2183+
dma_addr_t paddr = bo->dma_addr + fb->offsets[idx] + offsets[idx];
21702184

21712185
/* Pointer Word 0 */
21722186
vc4_state->ptr0_offset[i] = vc4_state->dlist_count;

0 commit comments

Comments
 (0)