Skip to content

Commit c941ffc

Browse files
committed
Merge tag 'drm-misc-fixes-2022-11-02-1' of git://anongit.freedesktop.org/drm/drm-misc into drm-fixes
drm-misc-fixes for v6.1-rc4: - Small fixes to make rockchip work better. - Fix imx Kconfig. - Small fix to imx' mode_valid. Signed-off-by: Dave Airlie <[email protected]> From: Maarten Lankhorst <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2 parents 30a0b95 + fc007fb commit c941ffc

File tree

7 files changed

+83
-33
lines changed

7 files changed

+83
-33
lines changed

drivers/gpu/drm/drm_format_helper.c

Lines changed: 47 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,38 @@ static bool is_listed_fourcc(const uint32_t *fourccs, size_t nfourccs, uint32_t
807807
return false;
808808
}
809809

810+
static const uint32_t conv_from_xrgb8888[] = {
811+
DRM_FORMAT_XRGB8888,
812+
DRM_FORMAT_ARGB8888,
813+
DRM_FORMAT_XRGB2101010,
814+
DRM_FORMAT_ARGB2101010,
815+
DRM_FORMAT_RGB565,
816+
DRM_FORMAT_RGB888,
817+
};
818+
819+
static const uint32_t conv_from_rgb565_888[] = {
820+
DRM_FORMAT_XRGB8888,
821+
DRM_FORMAT_ARGB8888,
822+
};
823+
824+
static bool is_conversion_supported(uint32_t from, uint32_t to)
825+
{
826+
switch (from) {
827+
case DRM_FORMAT_XRGB8888:
828+
case DRM_FORMAT_ARGB8888:
829+
return is_listed_fourcc(conv_from_xrgb8888, ARRAY_SIZE(conv_from_xrgb8888), to);
830+
case DRM_FORMAT_RGB565:
831+
case DRM_FORMAT_RGB888:
832+
return is_listed_fourcc(conv_from_rgb565_888, ARRAY_SIZE(conv_from_rgb565_888), to);
833+
case DRM_FORMAT_XRGB2101010:
834+
return to == DRM_FORMAT_ARGB2101010;
835+
case DRM_FORMAT_ARGB2101010:
836+
return to == DRM_FORMAT_XRGB2101010;
837+
default:
838+
return false;
839+
}
840+
}
841+
810842
/**
811843
* drm_fb_build_fourcc_list - Filters a list of supported color formats against
812844
* the device's native formats
@@ -827,7 +859,9 @@ static bool is_listed_fourcc(const uint32_t *fourccs, size_t nfourccs, uint32_t
827859
* be handed over to drm_universal_plane_init() et al. Native formats
828860
* will go before emulated formats. Other heuristics might be applied
829861
* to optimize the order. Formats near the beginning of the list are
830-
* usually preferred over formats near the end of the list.
862+
* usually preferred over formats near the end of the list. Formats
863+
* without conversion helpers will be skipped. New drivers should only
864+
* pass in XRGB8888 and avoid exposing additional emulated formats.
831865
*
832866
* Returns:
833867
* The number of color-formats 4CC codes returned in @fourccs_out.
@@ -839,7 +873,7 @@ size_t drm_fb_build_fourcc_list(struct drm_device *dev,
839873
{
840874
u32 *fourccs = fourccs_out;
841875
const u32 *fourccs_end = fourccs_out + nfourccs_out;
842-
bool found_native = false;
876+
uint32_t native_format = 0;
843877
size_t i;
844878

845879
/*
@@ -858,26 +892,18 @@ size_t drm_fb_build_fourcc_list(struct drm_device *dev,
858892

859893
drm_dbg_kms(dev, "adding native format %p4cc\n", &fourcc);
860894

861-
if (!found_native)
862-
found_native = is_listed_fourcc(driver_fourccs, driver_nfourccs, fourcc);
895+
/*
896+
* There should only be one native format with the current API.
897+
* This API needs to be refactored to correctly support arbitrary
898+
* sets of native formats, since it needs to report which native
899+
* format to use for each emulated format.
900+
*/
901+
if (!native_format)
902+
native_format = fourcc;
863903
*fourccs = fourcc;
864904
++fourccs;
865905
}
866906

867-
/*
868-
* The plane's atomic_update helper converts the framebuffer's color format
869-
* to a native format when copying to device memory.
870-
*
871-
* If there is not a single format supported by both, device and
872-
* driver, the native formats are likely not supported by the conversion
873-
* helpers. Therefore *only* support the native formats and add a
874-
* conversion helper ASAP.
875-
*/
876-
if (!found_native) {
877-
drm_warn(dev, "Format conversion helpers required to add extra formats.\n");
878-
goto out;
879-
}
880-
881907
/*
882908
* The extra formats, emulated by the driver, go second.
883909
*/
@@ -890,6 +916,9 @@ size_t drm_fb_build_fourcc_list(struct drm_device *dev,
890916
} else if (fourccs == fourccs_end) {
891917
drm_warn(dev, "Ignoring emulated format %p4cc\n", &fourcc);
892918
continue; /* end of available output buffer */
919+
} else if (!is_conversion_supported(fourcc, native_format)) {
920+
drm_dbg_kms(dev, "Unsupported emulated format %p4cc\n", &fourcc);
921+
continue; /* format is not supported for conversion */
893922
}
894923

895924
drm_dbg_kms(dev, "adding emulated format %p4cc\n", &fourcc);
@@ -898,7 +927,6 @@ size_t drm_fb_build_fourcc_list(struct drm_device *dev,
898927
++fourccs;
899928
}
900929

901-
out:
902930
return fourccs - fourccs_out;
903931
}
904932
EXPORT_SYMBOL(drm_fb_build_fourcc_list);

drivers/gpu/drm/imx/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ config DRM_IMX
44
select DRM_KMS_HELPER
55
select VIDEOMODE_HELPERS
66
select DRM_GEM_DMA_HELPER
7-
select DRM_KMS_HELPER
87
depends on DRM && (ARCH_MXC || ARCH_MULTIPLATFORM || COMPILE_TEST)
98
depends on IMX_IPUV3_CORE
109
help

drivers/gpu/drm/imx/imx-tve.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,9 @@ static int imx_tve_connector_get_modes(struct drm_connector *connector)
218218
return ret;
219219
}
220220

221-
static int imx_tve_connector_mode_valid(struct drm_connector *connector,
222-
struct drm_display_mode *mode)
221+
static enum drm_mode_status
222+
imx_tve_connector_mode_valid(struct drm_connector *connector,
223+
struct drm_display_mode *mode)
223224
{
224225
struct imx_tve *tve = con_to_tve(connector);
225226
unsigned long rate;

drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ static void dw_mipi_dsi_rockchip_config(struct dw_mipi_dsi_rockchip *dsi)
752752
static void dw_mipi_dsi_rockchip_set_lcdsel(struct dw_mipi_dsi_rockchip *dsi,
753753
int mux)
754754
{
755-
if (dsi->cdata->lcdsel_grf_reg < 0)
755+
if (dsi->cdata->lcdsel_grf_reg)
756756
regmap_write(dsi->grf_regmap, dsi->cdata->lcdsel_grf_reg,
757757
mux ? dsi->cdata->lcdsel_lit : dsi->cdata->lcdsel_big);
758758
}
@@ -1051,23 +1051,31 @@ static int dw_mipi_dsi_rockchip_host_attach(void *priv_data,
10511051
if (ret) {
10521052
DRM_DEV_ERROR(dsi->dev, "Failed to register component: %d\n",
10531053
ret);
1054-
return ret;
1054+
goto out;
10551055
}
10561056

10571057
second = dw_mipi_dsi_rockchip_find_second(dsi);
1058-
if (IS_ERR(second))
1059-
return PTR_ERR(second);
1058+
if (IS_ERR(second)) {
1059+
ret = PTR_ERR(second);
1060+
goto out;
1061+
}
10601062
if (second) {
10611063
ret = component_add(second, &dw_mipi_dsi_rockchip_ops);
10621064
if (ret) {
10631065
DRM_DEV_ERROR(second,
10641066
"Failed to register component: %d\n",
10651067
ret);
1066-
return ret;
1068+
goto out;
10671069
}
10681070
}
10691071

10701072
return 0;
1073+
1074+
out:
1075+
mutex_lock(&dsi->usage_mutex);
1076+
dsi->usage_mode = DW_DSI_USAGE_IDLE;
1077+
mutex_unlock(&dsi->usage_mutex);
1078+
return ret;
10711079
}
10721080

10731081
static int dw_mipi_dsi_rockchip_host_detach(void *priv_data,
@@ -1635,7 +1643,6 @@ static const struct rockchip_dw_dsi_chip_data rk3399_chip_data[] = {
16351643
static const struct rockchip_dw_dsi_chip_data rk3568_chip_data[] = {
16361644
{
16371645
.reg = 0xfe060000,
1638-
.lcdsel_grf_reg = -1,
16391646
.lanecfg1_grf_reg = RK3568_GRF_VO_CON2,
16401647
.lanecfg1 = HIWORD_UPDATE(0, RK3568_DSI0_SKEWCALHS |
16411648
RK3568_DSI0_FORCETXSTOPMODE |
@@ -1645,7 +1652,6 @@ static const struct rockchip_dw_dsi_chip_data rk3568_chip_data[] = {
16451652
},
16461653
{
16471654
.reg = 0xfe070000,
1648-
.lcdsel_grf_reg = -1,
16491655
.lanecfg1_grf_reg = RK3568_GRF_VO_CON3,
16501656
.lanecfg1 = HIWORD_UPDATE(0, RK3568_DSI1_SKEWCALHS |
16511657
RK3568_DSI1_FORCETXSTOPMODE |
@@ -1681,5 +1687,11 @@ struct platform_driver dw_mipi_dsi_rockchip_driver = {
16811687
.of_match_table = dw_mipi_dsi_rockchip_dt_ids,
16821688
.pm = &dw_mipi_dsi_rockchip_pm_ops,
16831689
.name = "dw-mipi-dsi-rockchip",
1690+
/*
1691+
* For dual-DSI display, one DSI pokes at the other DSI's
1692+
* drvdata in dw_mipi_dsi_rockchip_find_second(). This is not
1693+
* safe for asynchronous probe.
1694+
*/
1695+
.probe_type = PROBE_FORCE_SYNCHRONOUS,
16841696
},
16851697
};

drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,8 @@ static int dw_hdmi_rockchip_bind(struct device *dev, struct device *master,
565565

566566
ret = rockchip_hdmi_parse_dt(hdmi);
567567
if (ret) {
568-
DRM_DEV_ERROR(hdmi->dev, "Unable to parse OF data\n");
568+
if (ret != -EPROBE_DEFER)
569+
DRM_DEV_ERROR(hdmi->dev, "Unable to parse OF data\n");
569570
return ret;
570571
}
571572

drivers/gpu/drm/rockchip/rockchip_drm_gem.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,9 +364,12 @@ rockchip_gem_create_with_handle(struct drm_file *file_priv,
364364
{
365365
struct rockchip_gem_object *rk_obj;
366366
struct drm_gem_object *obj;
367+
bool is_framebuffer;
367368
int ret;
368369

369-
rk_obj = rockchip_gem_create_object(drm, size, false);
370+
is_framebuffer = drm->fb_helper && file_priv == drm->fb_helper->client.file;
371+
372+
rk_obj = rockchip_gem_create_object(drm, size, is_framebuffer);
370373
if (IS_ERR(rk_obj))
371374
return ERR_CAST(rk_obj);
372375

drivers/gpu/drm/rockchip/rockchip_drm_vop2.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -877,10 +877,14 @@ static void vop2_crtc_atomic_disable(struct drm_crtc *crtc,
877877
{
878878
struct vop2_video_port *vp = to_vop2_video_port(crtc);
879879
struct vop2 *vop2 = vp->vop2;
880+
struct drm_crtc_state *old_crtc_state;
880881
int ret;
881882

882883
vop2_lock(vop2);
883884

885+
old_crtc_state = drm_atomic_get_old_crtc_state(state, crtc);
886+
drm_atomic_helper_disable_planes_on_crtc(old_crtc_state, false);
887+
884888
drm_crtc_vblank_off(crtc);
885889

886890
/*
@@ -996,13 +1000,15 @@ static int vop2_plane_atomic_check(struct drm_plane *plane,
9961000
static void vop2_plane_atomic_disable(struct drm_plane *plane,
9971001
struct drm_atomic_state *state)
9981002
{
999-
struct drm_plane_state *old_pstate = drm_atomic_get_old_plane_state(state, plane);
1003+
struct drm_plane_state *old_pstate = NULL;
10001004
struct vop2_win *win = to_vop2_win(plane);
10011005
struct vop2 *vop2 = win->vop2;
10021006

10031007
drm_dbg(vop2->drm, "%s disable\n", win->data->name);
10041008

1005-
if (!old_pstate->crtc)
1009+
if (state)
1010+
old_pstate = drm_atomic_get_old_plane_state(state, plane);
1011+
if (old_pstate && !old_pstate->crtc)
10061012
return;
10071013

10081014
vop2_win_disable(win);

0 commit comments

Comments
 (0)