[PATCH v7 3/3] drm: Add GUD USB Display driver

Noralf Trønnes noralf at tronnes.org
Mon Mar 8 18:13:00 UTC 2021



Den 05.03.2021 17.31, skrev Noralf Trønnes:
> This adds a USB display driver with the intention that it can be
> used with future USB interfaced low end displays/adapters. The Linux
> gadget device driver will serve as the canonical device implementation.
> 

> diff --git a/drivers/gpu/drm/gud/gud_drv.c b/drivers/gpu/drm/gud/gud_drv.c

> +static int gud_probe(struct usb_interface *intf, const struct usb_device_id *id)
> +{

> +	num_formats_dev = ret;
> +	for (i = 0; i < num_formats_dev; i++) {
> +		const struct drm_format_info *info;
> +		size_t fmt_buf_size;
> +		u32 format;
> +
> +		format = gud_to_fourcc(formats_dev[i]);
> +		if (!format) {
> +			drm_dbg(drm, "Unsupported format: 0x%02x\n", formats_dev[i]);
> +			continue;
> +		}
> +
> +		if (format == GUD_DRM_FORMAT_R1)
> +			info = &gud_drm_format_r1;
> +		else if (format == GUD_DRM_FORMAT_RGB111)
> +			info = &gud_drm_format_rgb111;
> +		else
> +			info = drm_format_info(format);
> +
> +		switch (format) {
> +		case GUD_DRM_FORMAT_R1:
> +			fallthrough;
> +		case GUD_DRM_FORMAT_RGB111:
> +			xrgb8888_emulation_format = info;
> +			break;
> +		case DRM_FORMAT_RGB565:
> +			rgb565_supported = true;
> +			if (!xrgb8888_emulation_format)
> +				xrgb8888_emulation_format = info;
> +			break;
> +		case DRM_FORMAT_XRGB8888:
> +			xrgb8888_supported = true;
> +			break;
> +		};
> +
> +		fmt_buf_size = drm_format_info_min_pitch(info, 0, drm->mode_config.max_width) *
> +			       drm->mode_config.max_height;
> +		max_buffer_size = max(max_buffer_size, fmt_buf_size);
> +
> +		if (format == GUD_DRM_FORMAT_R1)

This line should be:

		if (format == GUD_DRM_FORMAT_R1 || format == GUD_DRM_FORMAT_RGB111)

There's also a bug in the format conversion functions that shows up on
transfers with widths that are not pixels per byte aligned. I've fixed
R1, I'll look at RGB111 tomorrow.

Noralf.

> +			continue; /* Internal not for userspace */
> +
> +		formats[num_formats++] = format;
> +	}



More information about the dri-devel mailing list