Commit c941ffc3 authored by Dave Airlie's avatar Dave Airlie
Browse files

Merge tag 'drm-misc-fixes-2022-11-02-1' of...

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: default avatarDave Airlie <airlied@redhat.com>
From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/5476ef52-f91a-c2bc-f4b2-d338216d1e11@linux.intel.com
parents 30a0b95b fc007fb8
Loading
Loading
Loading
Loading
+47 −19
Original line number Diff line number Diff line
@@ -807,6 +807,38 @@ static bool is_listed_fourcc(const uint32_t *fourccs, size_t nfourccs, uint32_t
	return false;
}

static const uint32_t conv_from_xrgb8888[] = {
	DRM_FORMAT_XRGB8888,
	DRM_FORMAT_ARGB8888,
	DRM_FORMAT_XRGB2101010,
	DRM_FORMAT_ARGB2101010,
	DRM_FORMAT_RGB565,
	DRM_FORMAT_RGB888,
};

static const uint32_t conv_from_rgb565_888[] = {
	DRM_FORMAT_XRGB8888,
	DRM_FORMAT_ARGB8888,
};

static bool is_conversion_supported(uint32_t from, uint32_t to)
{
	switch (from) {
	case DRM_FORMAT_XRGB8888:
	case DRM_FORMAT_ARGB8888:
		return is_listed_fourcc(conv_from_xrgb8888, ARRAY_SIZE(conv_from_xrgb8888), to);
	case DRM_FORMAT_RGB565:
	case DRM_FORMAT_RGB888:
		return is_listed_fourcc(conv_from_rgb565_888, ARRAY_SIZE(conv_from_rgb565_888), to);
	case DRM_FORMAT_XRGB2101010:
		return to == DRM_FORMAT_ARGB2101010;
	case DRM_FORMAT_ARGB2101010:
		return to == DRM_FORMAT_XRGB2101010;
	default:
		return false;
	}
}

/**
 * drm_fb_build_fourcc_list - Filters a list of supported color formats against
 *                            the device's native formats
@@ -827,7 +859,9 @@ static bool is_listed_fourcc(const uint32_t *fourccs, size_t nfourccs, uint32_t
 * be handed over to drm_universal_plane_init() et al. Native formats
 * will go before emulated formats. Other heuristics might be applied
 * to optimize the order. Formats near the beginning of the list are
 * usually preferred over formats near the end of the list.
 * usually preferred over formats near the end of the list. Formats
 * without conversion helpers will be skipped. New drivers should only
 * pass in XRGB8888 and avoid exposing additional emulated formats.
 *
 * Returns:
 * 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,
{
	u32 *fourccs = fourccs_out;
	const u32 *fourccs_end = fourccs_out + nfourccs_out;
	bool found_native = false;
	uint32_t native_format = 0;
	size_t i;

	/*
@@ -858,24 +892,16 @@ size_t drm_fb_build_fourcc_list(struct drm_device *dev,

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

		if (!found_native)
			found_native = is_listed_fourcc(driver_fourccs, driver_nfourccs, fourcc);
		*fourccs = fourcc;
		++fourccs;
	}

		/*
	 * The plane's atomic_update helper converts the framebuffer's color format
	 * to a native format when copying to device memory.
	 *
	 * If there is not a single format supported by both, device and
	 * driver, the native formats are likely not supported by the conversion
	 * helpers. Therefore *only* support the native formats and add a
	 * conversion helper ASAP.
		 * There should only be one native format with the current API.
		 * This API needs to be refactored to correctly support arbitrary
		 * sets of native formats, since it needs to report which native
		 * format to use for each emulated format.
		 */
	if (!found_native) {
		drm_warn(dev, "Format conversion helpers required to add extra formats.\n");
		goto out;
		if (!native_format)
			native_format = fourcc;
		*fourccs = fourcc;
		++fourccs;
	}

	/*
@@ -890,6 +916,9 @@ size_t drm_fb_build_fourcc_list(struct drm_device *dev,
		} else if (fourccs == fourccs_end) {
			drm_warn(dev, "Ignoring emulated format %p4cc\n", &fourcc);
			continue; /* end of available output buffer */
		} else if (!is_conversion_supported(fourcc, native_format)) {
			drm_dbg_kms(dev, "Unsupported emulated format %p4cc\n", &fourcc);
			continue; /* format is not supported for conversion */
		}

		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,
		++fourccs;
	}

out:
	return fourccs - fourccs_out;
}
EXPORT_SYMBOL(drm_fb_build_fourcc_list);
+0 −1
Original line number Diff line number Diff line
@@ -4,7 +4,6 @@ config DRM_IMX
	select DRM_KMS_HELPER
	select VIDEOMODE_HELPERS
	select DRM_GEM_DMA_HELPER
	select DRM_KMS_HELPER
	depends on DRM && (ARCH_MXC || ARCH_MULTIPLATFORM || COMPILE_TEST)
	depends on IMX_IPUV3_CORE
	help
+3 −2
Original line number Diff line number Diff line
@@ -218,7 +218,8 @@ static int imx_tve_connector_get_modes(struct drm_connector *connector)
	return ret;
}

static int imx_tve_connector_mode_valid(struct drm_connector *connector,
static enum drm_mode_status
imx_tve_connector_mode_valid(struct drm_connector *connector,
			     struct drm_display_mode *mode)
{
	struct imx_tve *tve = con_to_tve(connector);
+19 −7
Original line number Diff line number Diff line
@@ -752,7 +752,7 @@ static void dw_mipi_dsi_rockchip_config(struct dw_mipi_dsi_rockchip *dsi)
static void dw_mipi_dsi_rockchip_set_lcdsel(struct dw_mipi_dsi_rockchip *dsi,
					    int mux)
{
	if (dsi->cdata->lcdsel_grf_reg < 0)
	if (dsi->cdata->lcdsel_grf_reg)
		regmap_write(dsi->grf_regmap, dsi->cdata->lcdsel_grf_reg,
			mux ? dsi->cdata->lcdsel_lit : dsi->cdata->lcdsel_big);
}
@@ -1051,23 +1051,31 @@ static int dw_mipi_dsi_rockchip_host_attach(void *priv_data,
	if (ret) {
		DRM_DEV_ERROR(dsi->dev, "Failed to register component: %d\n",
					ret);
		return ret;
		goto out;
	}

	second = dw_mipi_dsi_rockchip_find_second(dsi);
	if (IS_ERR(second))
		return PTR_ERR(second);
	if (IS_ERR(second)) {
		ret = PTR_ERR(second);
		goto out;
	}
	if (second) {
		ret = component_add(second, &dw_mipi_dsi_rockchip_ops);
		if (ret) {
			DRM_DEV_ERROR(second,
				      "Failed to register component: %d\n",
				      ret);
			return ret;
			goto out;
		}
	}

	return 0;

out:
	mutex_lock(&dsi->usage_mutex);
	dsi->usage_mode = DW_DSI_USAGE_IDLE;
	mutex_unlock(&dsi->usage_mutex);
	return ret;
}

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[] = {
static const struct rockchip_dw_dsi_chip_data rk3568_chip_data[] = {
	{
		.reg = 0xfe060000,
		.lcdsel_grf_reg = -1,
		.lanecfg1_grf_reg = RK3568_GRF_VO_CON2,
		.lanecfg1 = HIWORD_UPDATE(0, RK3568_DSI0_SKEWCALHS |
					  RK3568_DSI0_FORCETXSTOPMODE |
@@ -1645,7 +1652,6 @@ static const struct rockchip_dw_dsi_chip_data rk3568_chip_data[] = {
	},
	{
		.reg = 0xfe070000,
		.lcdsel_grf_reg = -1,
		.lanecfg1_grf_reg = RK3568_GRF_VO_CON3,
		.lanecfg1 = HIWORD_UPDATE(0, RK3568_DSI1_SKEWCALHS |
					  RK3568_DSI1_FORCETXSTOPMODE |
@@ -1681,5 +1687,11 @@ struct platform_driver dw_mipi_dsi_rockchip_driver = {
		.of_match_table = dw_mipi_dsi_rockchip_dt_ids,
		.pm	= &dw_mipi_dsi_rockchip_pm_ops,
		.name	= "dw-mipi-dsi-rockchip",
		/*
		 * For dual-DSI display, one DSI pokes at the other DSI's
		 * drvdata in dw_mipi_dsi_rockchip_find_second(). This is not
		 * safe for asynchronous probe.
		 */
		.probe_type = PROBE_FORCE_SYNCHRONOUS,
	},
};
+2 −1
Original line number Diff line number Diff line
@@ -565,6 +565,7 @@ static int dw_hdmi_rockchip_bind(struct device *dev, struct device *master,

	ret = rockchip_hdmi_parse_dt(hdmi);
	if (ret) {
		if (ret != -EPROBE_DEFER)
			DRM_DEV_ERROR(hdmi->dev, "Unable to parse OF data\n");
		return ret;
	}
Loading