Generic USB Display driver
Subsystems (4)
PATCH v3 1/6 drm/client: Add drm_client_init_from_id()
In reply to Noralf Trønnesdrm_client_init_from_id() provides a way for clients to add a client based on the minor. drm_client_register() is changed to return whether it was registered or not depending on the unplugged status of the DRM device. Its only caller drm_fbdev_generic_setup() runs inside probe() so it doesn't have to check.
v2:
- Move drm_client_modeset_set() to a separate patch with added functions.
- Previous version had drm_client_init_from_id() call drm_client_register(). This put the client in a position where it could receive hotplugs during init in addition to akward error paths. Instead let drm_client_register() return status so clients can know if the DRM device is gone or not.
v3:
- Forgot to remove locking with the change in the previous version. No need for locking when drm_client_register() is not called.
--- drivers/gpu/drm/drm_client.c | 44 +++++++++++++++++++++++++++++++++++- include/drm/drm_client.h | 4 +++- 2 files changed, 46 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_client.c +43 -1
@@ -112,6 +112,36 @@ int drm_client_init(struct drm_device *dev, struct drm_client_dev *client, }EXPORT_SYMBOL (drm_client_init); +/** +* drm_client_init_from_id - Initialise a DRM client +* @minor_id: DRM minor id +* @client: DRM client +* @name: Client name +* @funcs: DRM client functions (optional) +* +* This function looks up the drm_device using the minor id and initializes the +* client using drm_client_init(). +* +* Returns: +* Zero on success or negative error code on failure. +*/ +int drm_client_init_from_id (unsigned int minor_id,struct drm_client_dev *client, +const char *name,const struct drm_client_funcs *funcs) +{ +struct drm_minor *minor; +int ret; + + minor =drm_minor_acquire (minor_id); +if (IS_ERR (minor)) +return PTR_ERR (minor); + + ret =drm_client_init (minor->dev, client, name, funcs); +drm_minor_release (minor); + +return ret; +} +EXPORT_SYMBOL (drm_client_init_from_id); +/** * drm_client_register - Register client * @client: DRM client
@@ -121,14 +151,26 @@ EXPORT_SYMBOL(drm_client_init);* drm_client_register() it is no longer permissible to call drm_client_release() * directly (outside the unregister callback), instead cleanup will happen * automatically on driver unload. +* +* Returns: +* True if the client has been registered, false if the DRM device has already +* been unregistered. */ -void drm_client_register (struct drm_client_dev *client) +bool drm_client_register (struct drm_client_dev *client) {struct drm_device *dev = client->dev; +int idx; + +if (!drm_dev_enter (client->dev, &idx)) +return false;mutex_lock (&dev->clientlist_mutex);list_add (&client->list, &dev->clientlist);mutex_unlock (&dev->clientlist_mutex); + +drm_dev_exit (idx); + +return true; }EXPORT_SYMBOL (drm_client_register);
include/drm/drm_client.h +3 -1
@@ -109,8 +109,10 @@ struct drm_client_dev {int drm_client_init (struct drm_device *dev,struct drm_client_dev *client,const char *name,const struct drm_client_funcs *funcs); +int drm_client_init_from_id (unsigned int minor_id,struct drm_client_dev *client, +const char *name,const struct drm_client_funcs *funcs);void drm_client_release (struct drm_client_dev *client); -void drm_client_register (struct drm_client_dev *client); +bool drm_client_register (struct drm_client_dev *client);void drm_client_dev_unregister (struct drm_device *dev);void drm_client_dev_hotplug (struct drm_device *dev);
Signature · 1 line
2.23.0
PATCH v3 2/6 drm/client: Add drm_client_modeset_disable()
In reply to Noralf TrønnesAdd a way for clients to disable all outputs.
--- drivers/gpu/drm/drm_client_modeset.c | 20 ++++++++++++++++++++ include/drm/drm_client.h | 1 + 2 files changed, 21 insertions(+)
drivers/gpu/drm/drm_client_modeset.c +20 -0
@@ -1225,3 +1225,23 @@ int drm_client_modeset_dpms(struct drm_client_dev *client, int mode)return ret; }EXPORT_SYMBOL (drm_client_modeset_dpms); + +/** +* drm_client_modeset_disable() - Disable all outputs +* @client: DRM client +* +* This function disables all outputs by first clearing the modeset array and +* then committing the empty modesets. +* +* Returns: +* Zero on success or negative error code on failure. +*/ +int drm_client_modeset_disable (struct drm_client_dev *client) +{ +mutex_lock (&client->modeset_mutex); +drm_client_modeset_release (client); +mutex_unlock (&client->modeset_mutex); + +return drm_client_modeset_commit (client); +} +EXPORT_SYMBOL (drm_client_modeset_disable);
include/drm/drm_client.h +1 -0
@@ -168,6 +168,7 @@ int drm_client_modeset_check(struct drm_client_dev *client);int drm_client_modeset_commit_locked (struct drm_client_dev *client);int drm_client_modeset_commit (struct drm_client_dev *client);int drm_client_modeset_dpms (struct drm_client_dev *client,int mode); +int drm_client_modeset_disable (struct drm_client_dev *client);/** * drm_client_for_each_modeset() - Iterate over client modesets
Signature · 1 line
2.23.0
v3 cover Generic USB Display driver
Hi,
A while back I had the idea to turn a Raspberry Pi Zero into a $5 USB to HDMI/SDTV/DSI/DPI display adapter.
This series adds a USB host driver and a device/gadget driver to achieve that.
The reason for calling it 'Generic' is so anyone can make a USB display/adapter against this driver, all that's needed is to add a USB vid:pid. I have done a microcontroller implementation hack just to see how that would work out[1] (which unconvered a couple of bugs in the host driver).
The contents of the previous cover letter has been moved to the wiki[2] since it was getting rather long.
I've made an image[3] with the gadget side set up for the Raspberry Pi for easy testing. Patch 4 is the only one needed for the host side.
Merge plan
I'm hoping to apply the remaining drm_client patches in time for 5.9. With that in place it's much easier to apply the patch for the USB subsystem the following merge window (5.10). Doing both in the same cycle is possible ofc, but due to the high rate of change in DRM this _can_ turn out to be tricky. There's no hurry to get the gadget side merged since I will provide images for the Raspberry Pi. The host driver I hope to apply in time for 5.9.
Reviews and testing are very much welcome!
Changes since version 2:
- Use donated Openmoko USB pid: 1d50:614d
- Use direct compression from framebuffer when pitch matches, not only on full frames, so split updates can benefit
- Use __le16 in struct gud_drm_req_get_connector_status
- Set edid property when the device only provides edid
- Clear compression fields in struct gud_drm_req_set_buffer
- Fix protocol version negotiation
- Remove mode->vrefresh, it's calculated
- drm_client_init_from_id(): remove locking
- Applied reviewed patches, thanks Sam.
Dependency:
- backlight: Add backlight_device_get_by_name()[4]
Noralf.
[1] https://github.com/notro/gud/tree/master/STM32F769I-DISCO
[2] https://github.com/notro/gud/wiki
[3] https://github.com/notro/gud/wiki/rpi-image
[4] https://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight.git/commit/?h=for-backlight-next&id=479da1f538a2f3547e15f9d5922c611b69ec2fbc
Noralf Trønnes (6):
drm/client: Add drm_client_init_from_id() drm/client: Add drm_client_modeset_disable() drm/client: Add a way to set modeset, properties and rotation
drm: Add Generic USB Display driver
drm/gud: Add functionality for the USB gadget side
usb: gadget: function: Add Generic USB Display support
.../ABI/testing/configfs-usb-gadget-gud_drm | 10 + MAINTAINERS | 10 + drivers/gpu/drm/Kconfig | 2 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/drm_client.c | 44 +- drivers/gpu/drm/drm_client_modeset.c | 157 +++ drivers/gpu/drm/gud/Kconfig | 20 + drivers/gpu/drm/gud/Makefile | 5 + drivers/gpu/drm/gud/gud_drm_connector.c | 726 ++++++++++ drivers/gpu/drm/gud/gud_drm_drv.c | 648 +++++++++ drivers/gpu/drm/gud/gud_drm_gadget.c | 1167 +++++++++++++++++ drivers/gpu/drm/gud/gud_drm_internal.h | 65 + drivers/gpu/drm/gud/gud_drm_pipe.c | 426 ++++++ drivers/usb/gadget/Kconfig | 12 + drivers/usb/gadget/function/Makefile | 2 + drivers/usb/gadget/function/f_gud_drm.c | 678 ++++++++++ include/drm/drm_client.h | 43 +- include/drm/gud_drm.h | 374 ++++++ 18 files changed, 4387 insertions(+), 3 deletions(-) create mode 100644 Documentation/ABI/testing/configfs-usb-gadget-gud_drm create mode 100644 drivers/gpu/drm/gud/Kconfig create mode 100644 drivers/gpu/drm/gud/Makefile create mode 100644 drivers/gpu/drm/gud/gud_drm_connector.c create mode 100644 drivers/gpu/drm/gud/gud_drm_drv.c create mode 100644 drivers/gpu/drm/gud/gud_drm_gadget.c create mode 100644 drivers/gpu/drm/gud/gud_drm_internal.h create mode 100644 drivers/gpu/drm/gud/gud_drm_pipe.c create mode 100644 drivers/usb/gadget/function/f_gud_drm.c create mode 100644 include/drm/gud_drm.h
Signature · 1 line
2.23.0
PATCH v3 3/6 drm/client: Add a way to set modeset, properties and rotation
This adds functions for clients that need more control over the configuration than what's setup by drm_client_modeset_probe(). Connector, fb and display mode can be set using drm_client_modeset_set(). Plane rotation can be set using drm_client_modeset_set_rotation() and other properties using drm_client_modeset_set_property(). Property setting is only implemented for atomic drivers.
v2:
- drm_client_modeset_set(): Remove undocumented functionality to clear modesets. A disable function takes care of that need now.
- drm_client_modeset_set_property(): Return -EOPNOTSUPP if driver is not atomic (Sam)
--- drivers/gpu/drm/drm_client_modeset.c | 137 +++++++++++++++++++++++++++ include/drm/drm_client.h | 38 +++++++- 2 files changed, 174 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_client_modeset.c +137 -0
@@ -83,6 +83,10 @@ static void drm_client_modeset_release(struct drm_client_dev *client) } modeset->num_connectors =0 ; } + +kfree (client->properties); + client->properties =NULL ; + client->num_properties =0 ; }void drm_client_modeset_free (struct drm_client_dev *client)
@@ -879,6 +883,130 @@ int drm_client_modeset_probe(struct drm_client_dev *client, unsigned int width, }EXPORT_SYMBOL (drm_client_modeset_probe); +/** +* drm_client_modeset_set() - Set modeset configuration +* @client: DRM client +* @connector: Connector +* @mode: Display mode +* @fb: Framebuffer +* +* This function releases any current modeset info, including properties, and +* sets the new modeset in the client's modeset array. +* +* Returns: +* Zero on success or negative error code on failure. +*/ +int drm_client_modeset_set (struct drm_client_dev *client,struct drm_connector *connector, +struct drm_display_mode *mode,struct drm_framebuffer *fb) +{ +struct drm_mode_set *modeset; +int ret = -ENOENT ; + +mutex_lock (&client->modeset_mutex); + +drm_client_modeset_release (client); + +drm_client_for_each_modeset (modeset, client) { +if (!connector_has_possible_crtc (connector, modeset->crtc)) +continue ; + + modeset->mode =drm_mode_duplicate (client->dev, mode); +if (!modeset->mode) { + ret = -ENOMEM ; +break ; + } + +drm_mode_set_crtcinfo (modeset->mode,CRTC_INTERLACE_HALVE_V ); + +drm_connector_get (connector); + modeset->connectors[modeset->num_connectors++] = connector; + + modeset->fb = fb; + ret =0 ; +break ; + } + +mutex_unlock (&client->modeset_mutex); + +return ret; +} +EXPORT_SYMBOL (drm_client_modeset_set); + +/** +* drm_client_modeset_set_property() - Set a property on the current configuration +* @client: DRM client +* @obj: DRM Mode Object +* @prop: DRM Property +* @value: Property value +* +* Note: Currently only implemented for atomic drivers. +* +* Returns: +* Zero on success or negative error code on failure. +*/ +int drm_client_modeset_set_property (struct drm_client_dev *client,struct drm_mode_object *obj, +struct drm_property *prop,u64 value) +{ +struct drm_client_property *properties; +int ret =0 ; + +if (!prop) +return -EINVAL ; + +if (!drm_drv_uses_atomic_modeset (client->dev)) +return -EOPNOTSUPP ; + +mutex_lock (&client->modeset_mutex); + + properties =krealloc (client->properties, + (client->num_properties +1 ) *sizeof (*properties),GFP_KERNEL ); +if (!properties) { + ret = -ENOMEM ; + goto unlock; + } + + properties[client->num_properties].obj = obj; + properties[client->num_properties].prop = prop; + properties[client->num_properties].value = value; + client->properties = properties; + client->num_properties++; +unlock: +mutex_unlock (&client->modeset_mutex); + +return ret; +} +EXPORT_SYMBOL (drm_client_modeset_set_property); + +/** +* drm_client_modeset_set_rotation() - Set rotation on the current configuration +* @client: DRM client +* @value: Rotation value +* +* Returns: +* Zero on success or negative error code on failure. +*/ +int drm_client_modeset_set_rotation (struct drm_client_dev *client,u64 value) +{ +struct drm_plane *plane =NULL ; +struct drm_mode_set *modeset; + +mutex_lock (&client->modeset_mutex); +drm_client_for_each_modeset (modeset, client) { +if (modeset->mode) { + plane = modeset->crtc->primary; +break ; + } + } +mutex_unlock (&client->modeset_mutex); + +if (!plane) +return -ENOENT ; + +return drm_client_modeset_set_property (client, &plane->base, + plane->rotation_property, value); +} +EXPORT_SYMBOL (drm_client_modeset_set_rotation); +/** * drm_client_rotation() - Check the initial rotation value * @modeset: DRM modeset
@@ -973,6 +1101,7 @@ static int drm_client_modeset_commit_atomic(struct drm_client_dev *client, boolstruct drm_atomic_state *state;struct drm_modeset_acquire_ctx ctx;struct drm_mode_set *mode_set; +unsigned int i;int ret;drm_modeset_acquire_init (&ctx,0 );
@@ -1033,6 +1162,14 @@ static int drm_client_modeset_commit_atomic(struct drm_client_dev *client, bool } } +for (i =0 ; i < client->num_properties; i++) { +struct drm_client_property *prop = &client->properties[i]; + + ret =drm_atomic_set_property (state,NULL , prop->obj, prop->prop, prop->value); +if (ret) + goto out_state; + } +if (check) ret =drm_atomic_check_only (state);else
include/drm/drm_client.h +37 -1
@@ -16,6 +16,7 @@ struct drm_file;struct drm_framebuffer ;struct drm_gem_object ;struct drm_minor ; +struct drm_property ;struct module ;/**
@@ -64,6 +65,26 @@ struct drm_client_funcs {int (*hotplug)(struct drm_client_dev *client); }; +/** +* struct drm_client_property - DRM client property +*/ +struct drm_client_property { +/** +* @obj: DRM Mode Object to which the property belongs. +*/ +struct drm_mode_object *obj; + +/** +* @prop: DRM Property. +*/ +struct drm_property *prop; + +/** +* @value: Property value. +*/ +u64 value; +}; +/** * struct drm_client_dev - DRM client instance */
@@ -97,7 +118,7 @@ struct drm_client_dev {struct drm_file *file;/** -* @modeset_mutex: Protects @modesets. +* @modeset_mutex: Protects @modesets and @properties. */ struct mutex modeset_mutex;
@@ -105,6 +126,16 @@ struct drm_client_dev {* @modesets: CRTC configurations */ struct drm_mode_set *modesets; + +/** +* @properties: DRM properties attached to the configuration. +*/ +struct drm_client_property *properties; + +/** +* @num_properties: Number of attached properties. +*/ +unsigned int num_properties; }; int drm_client_init(struct drm_device *dev, struct drm_client_dev *client,
@@ -163,6 +194,11 @@ void drm_client_buffer_vunmap(struct drm_client_buffer *buffer);int drm_client_modeset_create (struct drm_client_dev *client);void drm_client_modeset_free (struct drm_client_dev *client);int drm_client_modeset_probe (struct drm_client_dev *client,unsigned int width,unsigned int height); +int drm_client_modeset_set (struct drm_client_dev *client,struct drm_connector *connector, +struct drm_display_mode *mode,struct drm_framebuffer *fb); +int drm_client_modeset_set_property (struct drm_client_dev *client,struct drm_mode_object *obj, +struct drm_property *prop,u64 value); +int drm_client_modeset_set_rotation (struct drm_client_dev *client,u64 value);bool drm_client_rotation (struct drm_mode_set *modeset,unsigned int *rotation);int drm_client_modeset_check (struct drm_client_dev *client);int drm_client_modeset_commit_locked (struct drm_client_dev *client);
Signature · 1 line
2.23.0
PATCH v3 6/6 usb: gadget: function: Add Generic USB Display support
In reply to Noralf TrønnesThis adds the gadget side support for the Generic USB Display. It presents a DRM display device as a USB Display configured through configfs.
The display is implemented as a vendor type USB interface with one bulk out endpoint. The protocol is implemented using control requests. lz4 compressed framebuffer data/pixels are sent over the bulk endpoint.
The DRM part of the gadget is placed in the DRM subsystem since it reaches into the DRM internals.
--- .../ABI/testing/configfs-usb-gadget-gud_drm | 10 + MAINTAINERS | 2 + drivers/usb/gadget/Kconfig | 12 + drivers/usb/gadget/function/Makefile | 2 + drivers/usb/gadget/function/f_gud_drm.c | 678 ++++++++++++++++++ 5 files changed, 704 insertions(+) create mode 100644 Documentation/ABI/testing/configfs-usb-gadget-gud_drm create mode 100644 drivers/usb/gadget/function/f_gud_drm.c
Documentation/ABI/testing/configfs-usb-gadget-gud_drm new file +10 -0
@@ -0,0 +1,10 @@ +What: /config/usb-gadget/gadget/functions/gud_drm.name +Date: Dec 2020 +KernelVersion: 5.10 +Description: + The attributes: + + drm_dev - DRM device number + backlight_dev - Backlight device name (optional) + The backlight brightness scale should be + perceptual not linear.
MAINTAINERS +2 -0
@@ -5296,7 +5296,9 @@ M: Noralf Trønnes <[email protected]> S: Maintained W: https://github.com/notro/gud/wiki T: git git://anongit.freedesktop.org/drm/drm-misc +F: Documentation/ABI/testing/configfs-usb-gadget-gud_drm F: drivers/gpu/drm/gud/ +F: drivers/usb/gadget/function/f_gud_drm.c F: include/drm/gud_drm.h DRM DRIVER FOR GRAIN MEDIA GM12U320 PROJECTORS
drivers/usb/gadget/Kconfig +12 -0
@@ -216,6 +216,9 @@ config USB_F_PRINTER config USB_F_TCM tristate +config USB_F_GUD_DRM + tristate + # this first set of drivers all depend on bulk-capable hardware. config USB_CONFIGFS
@@ -483,6 +486,15 @@ config USB_CONFIGFS_F_TCM Both protocols can work on USB2.0 and USB3.0. UAS utilizes the USB 3.0 feature called streams support. +config USB_CONFIGFS_F_GUD_DRM + bool "Generic USB Display Gadget function" + depends on USB_CONFIGFS + depends on DRM + select DRM_GUD_GADGET + select USB_F_GUD_DRM + help + This presents a DRM display device as a Generic USB Display. + source "drivers/usb/gadget/legacy/Kconfig" endif # USB_GADGET
drivers/usb/gadget/function/Makefile +2 -0
@@ -50,3 +50,5 @@ usb_f_printer-y := f_printer.o obj-$(CONFIG_USB_F_PRINTER) += usb_f_printer.o usb_f_tcm-y := f_tcm.o obj-$(CONFIG_USB_F_TCM) += usb_f_tcm.o +usb_f_gud_drm-y := f_gud_drm.o +obj-$(CONFIG_USB_F_GUD_DRM) += usb_f_gud_drm.o
drivers/usb/gadget/function/f_gud_drm.c new file +678 -0
678 lines not on this page · raw message
Signature · 1 line
2.23.0
PATCH v3 5/6 drm/gud: Add functionality for the USB gadget side
In reply to Noralf TrønnesSince the USB gadget/device has to reach into the DRM internals, part of the code is placed in the DRM subsystem as a separate module. All calls into this module runs in process context and are serialized, except one function that runs in interrupt context.
Since both the gadget side and the DRM side can disable the gadget, special care has been taken to make that safe.
v2:
- Use drm_client_modeset_disable()
--- drivers/gpu/drm/gud/Kconfig | 6 + drivers/gpu/drm/gud/Makefile | 1 + drivers/gpu/drm/gud/gud_drm_gadget.c | 1167 ++++++++++++++++++++++++++ include/drm/gud_drm.h | 13 + 4 files changed, 1187 insertions(+) create mode 100644 drivers/gpu/drm/gud/gud_drm_gadget.c
drivers/gpu/drm/gud/Kconfig +6 -0
@@ -12,3 +12,9 @@ config DRM_GUD adapters. If M is selected the module will be called gud_drm. + +config DRM_GUD_GADGET + tristate + depends on DRM + select LZ4_DECOMPRESS + select BACKLIGHT_CLASS_DEVICE
drivers/gpu/drm/gud/Makefile +1 -0
@@ -2,3 +2,4 @@ gud_drm-objs := gud_drm_drv.o gud_drm_pipe.o gud_drm_connector.o obj-$(CONFIG_DRM_GUD) += gud_drm.o +obj-$(CONFIG_DRM_GUD_GADGET) += gud_drm_gadget.o
drivers/gpu/drm/gud/gud_drm_gadget.c new file +1167 -0
1,167 lines not on this page · raw message
include/drm/gud_drm.h +13 -0
@@ -358,4 +358,17 @@ static inline void gud_drm_to_display_mode(struct drm_display_mode *dst, drm_mode_set_name(dst); } +struct gud_drm_gadget ; + +struct gud_drm_gadget *gud_drm_gadget_init (unsigned int minor_id,const char *backlight, +size_t *max_buffer_size); +void gud_drm_gadget_fini (struct gud_drm_gadget *gdg); +int gud_drm_gadget_disable_pipe (struct gud_drm_gadget *gdg); +int gud_drm_gadget_ctrl_get (struct gud_drm_gadget *gdg,u8 request, +u16 index,void *data,size_t size); +int gud_drm_gadget_ctrl_set (struct gud_drm_gadget *gdg,u8 request, +u16 index,void *data,size_t size); +int gud_drm_gadget_set_buffer (struct gud_drm_gadget *gdg,struct gud_drm_req_set_buffer *req); +int gud_drm_gadget_write_buffer (struct gud_drm_gadget *gdg,const void *buf,size_t len); +#endif
Signature · 6 lines
2.23.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v3 4/6 drm: Add Generic USB Display driver
In reply to Noralf TrønnesThis adds a generic 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.
The following DRM properties are supported:
- Plane rotation
- Connector TV properties
There is also support for backlight brightness exposed as a backlight device.
Display modes can be made available to the host driver either as DRM display modes or through EDID. If both are present, EDID is just passed on to userspace.
Performance is preferred over color depth, so if the device supports RGB565, DRM_CAP_DUMB_PREFERRED_DEPTH will return 16.
If the device transfer buffer can't fit an uncompressed framebuffer update, the update is split up into parts that do fit.
Optimal user experience is achieved by providing damage reports either by setting FB_DAMAGE_CLIPS on pageflips or calling DRM_IOCTL_MODE_DIRTYFB.
LZ4 compression is used if the device supports it.
The driver supports a one bit monochrome transfer format: R1. This is not implemented in the gadget driver. It is added in preparation for future monochrome e-ink displays.
The driver is MIT licensed to smooth the path for any BSD port of the driver.
v2:
- Use devm_drm_dev_alloc() and drmm_mode_config_init()
- drm_fbdev_generic_setup: Use preferred_bpp=0, 16 was a copy paste error
- The drm_backlight_helper is dropped, copy in the code
- Support protocol version backwards compatibility for device
v3:
- Use donated Openmoko USB pid
- Use direct compression from framebuffer when pitch matches, not only on full frames, so split updates can benefit
- Use __le16 in struct gud_drm_req_get_connector_status
- Set edid property when the device only provides edid
- Clear compression fields in struct gud_drm_req_set_buffer
- Fix protocol version negotiation
- Remove mode->vrefresh, it's calculated
--- MAINTAINERS | 8 + drivers/gpu/drm/Kconfig | 2 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/gud/Kconfig | 14 + drivers/gpu/drm/gud/Makefile | 4 + drivers/gpu/drm/gud/gud_drm_connector.c | 726 ++++++++++++++++++++++++ drivers/gpu/drm/gud/gud_drm_drv.c | 648 +++++++++++++++++++++ drivers/gpu/drm/gud/gud_drm_internal.h | 65 +++ drivers/gpu/drm/gud/gud_drm_pipe.c | 426 ++++++++++++++ include/drm/gud_drm.h | 361 ++++++++++++ 10 files changed, 2255 insertions(+) create mode 100644 drivers/gpu/drm/gud/Kconfig create mode 100644 drivers/gpu/drm/gud/Makefile create mode 100644 drivers/gpu/drm/gud/gud_drm_connector.c create mode 100644 drivers/gpu/drm/gud/gud_drm_drv.c create mode 100644 drivers/gpu/drm/gud/gud_drm_internal.h create mode 100644 drivers/gpu/drm/gud/gud_drm_pipe.c create mode 100644 include/drm/gud_drm.h
MAINTAINERS +8 -0
@@ -5291,6 +5291,14 @@ S: Maintained F: drivers/gpu/drm/panel/panel-feiyang-fy07024di26a30d.c F: Documentation/devicetree/bindings/display/panel/feiyang,fy07024di26a30d.yaml +DRM DRIVER FOR GENERIC USB DISPLAY +M: Noralf Trønnes <[email protected]> +S: Maintained +W: https://github.com/notro/gud/wiki +T: git git://anongit.freedesktop.org/drm/drm-misc +F: drivers/gpu/drm/gud/ +F: include/drm/gud_drm.h + DRM DRIVER FOR GRAIN MEDIA GM12U320 PROJECTORS M: Hans de Goede <[email protected]> S: Maintained
drivers/gpu/drm/Kconfig +2 -0
@@ -391,6 +391,8 @@ source "drivers/gpu/drm/mcde/Kconfig" source "drivers/gpu/drm/tidss/Kconfig" +source "drivers/gpu/drm/gud/Kconfig" + # Keep legacy drivers last menuconfig DRM_LEGACY
drivers/gpu/drm/Makefile +1 -0
@@ -124,3 +124,4 @@ obj-$(CONFIG_DRM_PANFROST) += panfrost/ obj-$(CONFIG_DRM_ASPEED_GFX) += aspeed/ obj-$(CONFIG_DRM_MCDE) += mcde/ obj-$(CONFIG_DRM_TIDSS) += tidss/ +obj-y += gud/
drivers/gpu/drm/gud/Kconfig new file +14 -0
@@ -0,0 +1,14 @@ +# SPDX-License-Identifier: GPL-2.0 + +config DRM_GUD + tristate "Generic USB Display" + depends on DRM && USB + select LZ4_COMPRESS + select DRM_KMS_HELPER + select DRM_GEM_SHMEM_HELPER + select BACKLIGHT_CLASS_DEVICE + help + This is a DRM display driver for Generic USB Displays or display + adapters. + + If M is selected the module will be called gud_drm.
drivers/gpu/drm/gud/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 + +gud_drm-objs := gud_drm_drv.o gud_drm_pipe.o gud_drm_connector.o +obj-$(CONFIG_DRM_GUD) += gud_drm.o
drivers/gpu/drm/gud/gud_drm_connector.c new file +726 -0
726 lines not on this page · raw message
drivers/gpu/drm/gud/gud_drm_drv.c new file +648 -0
648 lines not on this page · raw message
drivers/gpu/drm/gud/gud_drm_internal.h new file +65 -0
65 lines not on this page · raw message
drivers/gpu/drm/gud/gud_drm_pipe.c new file +426 -0
426 lines not on this page · raw message
include/drm/gud_drm.h new file +361 -0
361 lines not on this page · raw message
Signature · 1 line
2.23.0
Re: [PATCH v3 4/6] drm: Add Generic USB Display driver
Hi Noralf,
Quoted 2 lines · Noralf Trønnes
This adds a generic USB display driver with the intention that it can be used with future USB interfaced low end displays/adapters.
Fun!
Quoted 2 lines
The Linux gadget device driver will serve as the canonical device implementation.
That's a great goal, but as proposed it isn't as generic as I would like.
Several Linux/DRM internals have "leaked" into the USB protocol - this should be avoided if you want device implementations other than your gadget, because those internals can change within Linux in the future, while the protocol must not.
Quoted 2 lines
If the device transfer buffer can't fit an uncompressed framebuffer update, the update is split up into parts that do fit.
Does "device transfer buffer" refer to something like display RAM on the device side? If so, its size is a device implementation detail which shouldn't be exposed over USB.
It's true that the host drives USB communication but the device decides whether it will accept data or not. If not, it responds with a NAK handshake in the OUT transaction, and the host controller will then try to resend the data later, until the transfer timeout given by the host software expires. Retries are invisible to host software.
The point is: USB has native flow control on the lowest level; that's far more efficient than anything the application can construct, and flow control in the application protocol would be redundant.
When using gadgetfs IIRC device controllers NAK as long as the userspace process doesn't write new data to the ep?out-bulk fd. Have you tried/seen this?
Quoted 3 lines
The driver supports a one bit monochrome transfer format: R1. This is not implemented in the gadget driver. It is added in preparation for future monochrome e-ink displays.
The R1 idea is great!
Quoted 1 line
- Use donated Openmoko USB pid
If Linux will be the reference for this protocol then perhaps a PID under the Linux Foundation VID (1d6b) makes more sense?
But: A PID applies on device level, not to interfaces.
Until this protocol becomes a USB-IF device class maybe it's better to create a probe for GUD interface(s) rather than binding to PID?
Does the driver btw. already support a composite device with multiple GUD interfaces? Say a microcontroller with two independent panels. It seems no?
If yes, would any of the control requests currently sent to the interface be better directed at the device? If so, then a PID might make sense again, but it's still not possible to create a composite device which uses this protocol, without risking collissions with other vendor specific requests on other (vendor specific) interfaces, that would be a real shame.
I can imagine a composite device wanting to implement HID and GUD, let's make sure that it's possible.
On to the code.
drivers/gpu/drm/gud/gud_drm_drv.c line 45
Quoted 5 lines
drivers/gpu/drm/gud/gud_drm_drv.c new file +5
-0+static int gud_drm_usb_control_msg (struct usb_device *usb,u8 ifnum,bool in, +u8 request,u16 value,void *buf,size_t len, +bool check_len) +{ +u8 requesttype =USB_TYPE_VENDOR |USB_RECIP_INTERFACE ;
This takes struct usb_device rather than struct usb_interface - again, would this actually work with a composite device? The driver doesn't ever claim the interface so I guess no?
Quoted 3 lines
drivers/gpu/drm/gud/gud_drm_drv.c new file +3
-0+static int gud_get_vendor_descriptor (struct usb_interface *interface, +struct gud_drm_display_descriptor *desc) +{
..
drivers/gpu/drm/gud/gud_drm_drv.c line 83
Quoted 2 lines
drivers/gpu/drm/gud/gud_drm_drv.c new file +2
-0+ ret =gud_drm_usb_control_msg (usb, ifnum, true,USB_REQ_GET_DESCRIPTOR , +GUD_DRM_USB_DT_DISPLAY <<8 , buf,sizeof (*desc), false);
GUD_DRM_USB_DT_DISPLAY is defined as (USB_TYPE_VENDOR | 0x4), but USB_TYPE_VENDOR only applies to bmRequestType[6:5] in control transfers, nowhere else. I know of no standardized way to introduce vendor-specific descriptors. Squatting is possible, but I think it would be nice to do better here. It is easy enough.
It could be argued that the vendor specific interface gives flexibility here, but actually it just means that the semantics of the standardized and well-defined USB_REQ_GET_DESCRIPTOR have been duplicated by this protocol, that is not very common - but if you want to go ahead then at least drop USB_TYPE_VENDOR from the GUD_DRM_USB_DT_DISPLAY definition.
Maybe it's good to think about the data exchange some more - anything not transfered by standardized USB_REQ_GET_DESCRIPTOR (bmRequestType 10000000B; Device-to-host data, Standard type, Device recipient) isn't actually a descriptor, it's vendor-specific, free-format data. Does that enable any simplifications?
drivers/gpu/drm/gud/gud_drm_drv.c line 120
Quoted 12 lines
drivers/gpu/drm/gud/gud_drm_drv.c new file +12
-0+static int gud_usb_get_status (struct usb_device *usb,u8 ifnum) +{ +struct gud_drm_req_get_status *status; +int ret, status_retries =2000 /5 ;/* maximum wait ~2 seconds */ +unsigned long delay =500 ; + + status =kmalloc (sizeof (*status),GFP_KERNEL ); +if (!status) +return -ENOMEM ; + +/* +* Poll due to lack of data/status stage control on the gadget side.
I hope we can find something better here.
Doesn't gadgetfs allow userspace to (indirectly) control the status stage, as I wrote above?
drivers/gpu/drm/gud/gud_drm_drv.c line 125
Quoted 4 lines
drivers/gpu/drm/gud/gud_drm_drv.c new file +4
-0+* If we did not use polling and gave up here after waiting 2 seconds, +* the worker in the gadget would finally get to queuing up the status +* respons, but by that time the host has moved on. The gadget side +* (at least dwc2) would now be left in a non-recoverable state.
Independently of the above, how does the gadget become non-recoverable?
If a transfer times out on the host without other error then the device has replied with NAK in the data stage transactions sent by the host until the host stopped trying. The device controller then sees no further data stage transactions and shouldn't be in a weird state?
drivers/gpu/drm/gud/gud_drm_drv.c line 132
Quoted 6 lines
drivers/gpu/drm/gud/gud_drm_drv.c new file +6
-0+* Worst case commit timeout in DRM can be tens of seconds (wait for +* various _done completions). +*/ +while (status_retries--) { + ret =gud_drm_usb_control_msg (usb, ifnum, true,USB_REQ_GET_STATUS ,0 , + status,sizeof (*status), true);
Instead of this loop a single request with 2000 ms timeout would avoid software overhead on the host. The header file says that 0 == PENDING is the only exit condition for the loop besides timeout, as long as there are no other conditions it's better to just wait for the timeout.
drivers/gpu/drm/gud/gud_drm_drv.c line 137
Quoted 2 lines
drivers/gpu/drm/gud/gud_drm_drv.c new file +2
-0+if (!(status->flags &GUD_DRM_STATUS_PENDING )) { + ret = -status->errno;
So this exposes errno (an implementation detail) in the bus protocol, at an absolute minimum it needs some le_to_cpu() adjustment, but I think it would be cleaner to define the specific errors that are application relevant.
If this get_status thing is in fact really really required then how about adding an interrupt IN endpoint for it? I think that would be cleaner and it costs less bus time with arguably lower latency. See e.g. usblp.
Quoted 4 lines
drivers/gpu/drm/gud/gud_drm_drv.c new file +4
-0+static struct drm_gem_object * +gud_drm_driver_gem_create_object (struct drm_device *dev,size_t size) +{ +struct drm_gem_shmem_object *shmem;
..
drivers/gpu/drm/gud/gud_drm_drv.c line 295
Quoted 6 lines
drivers/gpu/drm/gud/gud_drm_drv.c new file +6
-0+/* +* This doesn't make a difference on x86, but on ARM (pi4) it was +* necessary to avoid black lines all over and it made it possible to +* compress directly from the framebuffer without performance drop. +*/ + shmem->map_cached = true;
Can you explain what this does exactly?
Quoted 3 lines
drivers/gpu/drm/gud/gud_drm_drv.c new file +3
-0+static int gud_drm_probe (struct usb_interface *interface, +const struct usb_device_id *id) +{
..
Quoted 1 line
drivers/gpu/drm/gud/gud_drm_drv.c new file +1
-0+struct gud_drm_display_descriptor desc;
..
drivers/gpu/drm/gud/gud_drm_drv.c line 430
Quoted 10 lines
drivers/gpu/drm/gud/gud_drm_drv.c new file +10
-0+/* Check if the device can support us */ + *version =1 ; + ret =gud_drm_usb_control_msg (usb, ifnum, false,GUD_DRM_USB_REQ_SET_VERSION , +0 , version,sizeof (*version), true); +if (!ret) + ret =gud_usb_get_status (usb, ifnum); +kfree (version); +if (ret) { +dev_err (dev,"Protocol version %u is not supported\n" , desc.bVersion); +return -EPROTONOSUPPORT ;
Could't this work without _get_status()? What does usb_control_msg() return for a STALL handshake in the data stage?
Anyway, usb_get_status() (which I guess inspired gud_usb_get_status()) is usually for administrative device status rather than application status. Ideally the application status can be deduced by host software based on device responses.
..
drivers/gpu/drm/gud/gud_drm_drv.c line 451
Quoted 1 line
drivers/gpu/drm/gud/gud_drm_drv.c new file +1
-0+ gdrm->compression = desc.bCompression &GUD_DRM_COMPRESSION_LZ4 ;
This is a perfect example of doing things right! :)
GUD_DRM_COMPRESSION_LZ4 is specific for this protocol, not DRM/Linux.
What do you think about s,GUD_DRM_,GUD_, for such names?
And would it make sense to expose the protocol (names, structures) in uapi?
Or at least in Documentation/ ?
Quoted 4 lines
drivers/gpu/drm/gud/gud_drm_pipe.c new file +4
-0+static size_t gud_drm_xrgb8888_to_r124 (u8 *dst,const struct drm_format_info *format, +void *src,struct drm_framebuffer *fb, +struct drm_rect *rect) +{
..
drivers/gpu/drm/gud/gud_drm_pipe.c line 56
Quoted 3 lines
drivers/gpu/drm/gud/gud_drm_pipe.c new file +3
-0+ buf =kmalloc (width * height,GFP_KERNEL ); +if (!buf) +return len;/* To keep logic simple, just transmit garbage */
Ouch! Shouldn't this bubble up somehow? If there is memory pressure then I really think something above should fail.
drivers/gpu/drm/gud/gud_drm_pipe.c line 80
Quoted 3 lines
drivers/gpu/drm/gud/gud_drm_pipe.c new file +3
-0+static int gud_drm_fb_flush (struct gud_drm_device *gdrm,struct drm_framebuffer *fb, +const struct drm_format_info *format,struct drm_rect *rect) +{
This is in the hot path, right?
drivers/gpu/drm/gud/gud_drm_pipe.c line 176
Quoted 6 lines
drivers/gpu/drm/gud/gud_drm_pipe.c new file +6
-0+ ret =gud_drm_usb_set (gdrm,GUD_DRM_USB_REQ_SET_BUFFER ,0 , &req,sizeof (req)); +if (ret) + goto vunmap; + + ret =usb_bulk_msg (gdrm->usb, gdrm->bulk_pipe, gdrm->bulk_buf, trlen, + &actual_length,msecs_to_jiffies (3000 ));
I would definitely change this pattern so that the hot path has only bulk transactions, ideally a single transfer. The control transfer wastes precious bus time in the hot path.
Maybe it's insignificant with FHD data but then again, the more data the less overhead we want, and in any case for small R1 data the control transfer is easily more expensive than the data itself!
A control transfer somehow compares to an ioctl() from userspace with much context switching, while a bulk transfer is more like mmaped kernel memory or aio.
Why not just add the values in struct gud_drm_req_set_buffer as a header before the data instead?
That would mean two bulk transfers, but they could be asynchronous, at least the first, but making both async would also fit more data onto the bus. Maybe later.
include/drm/gud_drm.h line 112
Quoted 7 lines
+ * struct
gud_drm_req_get_connector- Connector descriptor
+ * @connector_type: Connector type (DRM_MODE_CONNECTOR_*)
+ * @flags: Flags
+ * @num_properties: Number of supported properties
+ */include/drm/gud_drm.h new file +2
-0+struct gud_drm_req_get_connector { +__u8 connector_type;
This is intended for the (Generic) USB Display to report the connector type used for its panel, right? It should not use Linux/DRM-internal values such as DRM_MODE_CONNECTOR_SPI to do so, if it wants to be generic and stable over time.
Why does the host software need to know anything about the connector inside the device, anyway? With a microcontroller that could be anything, especially with actual R1 displays.
Would it make sense to introduce DRM_MODE_CONNECTOR_USB on the host, and keep this implementation detail in the device?
Make the protocol application specific and avoid implementation specifics.
Quoted 1 line
+ * struct
gud_drm_req_get_connector_status- Connector status
How does this work if and when the status on the device changes?
include/drm/gud_drm.h line 189
Quoted 5 lines
include/drm/gud_drm.h new file +5
-0+/* +* Internal monochrome transfer format presented to userspace as XRGB8888. +* Pixel lines are byte aligned. +*/ +#define GUD_DRM_FORMAT_R1 fourcc_code('R', '1', ' ', ' ')
This is also a data format over USB, right? Then it's not really internal, because it also exists on the device. I have several uses for this, but none will be using Linux gadgets, rather microcontrollers.
include/drm/gud_drm.h line 237
Quoted 9 lines
include/drm/gud_drm.h new file +9
-0+/* USB Control requests: */ + +/* +* If the host driver doesn't support the device protocol version it will send +* the versions it supports starting with the latest. If the device isn't +* backwards compatible or doesn't support the version the host suggests, it +* shall return EPROTONOSUPPORT. +*/ +#define GUD_DRM_USB_REQ_SET_VERSION 0x30
USB devices report errors to a control requests with a STALL handshake, which is passed all the way back to the host software. Please use that?
How/where would the EPROTONOSUPPORT value be returned? It's another implementation specific, that should be used on the bus.
include/drm/gud_drm.h line 240
Quoted 2 lines
include/drm/gud_drm.h new file +2
-0+/* Get supported pixel formats as an array of fourcc codes. See include/uapi/drm/drm_fourcc.h */ +#define GUD_DRM_USB_REQ_GET_FORMATS 0x40
Plus R1, right? I can understand if you don't want to add R1 to uapi, but then at least document that the array can contain both uapi codes and R1.
include/drm/gud_drm.h line 275
Quoted 2 lines
include/drm/gud_drm.h new file +2
-0+/* Apply the prevoius _STATE_CHECK configuration */ +#define GUD_DRM_USB_REQ_SET_STATE_COMMIT 0x62
Typo -> previous
I hope this helps.
Kind regards
//Peter
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 4/6] drm: Add Generic USB Display driver
Hi Peter,
Den 30.05.2020 00.45, skrev Peter Stuge:
Quoted 12 lines
Hi Noralf,
Quoted 2 lines · Noralf Trønnes
This adds a generic USB display driver with the intention that it can be used with future USB interfaced low end displays/adapters.
Fun!
Quoted 2 lines
The Linux gadget device driver will serve as the canonical device implementation.
Quoted 7 lines
That's a great goal, but as proposed it isn't as generic as I would like.
Several Linux/DRM internals have "leaked" into the USB protocol - this should be avoided if you want device implementations other than your gadget, because those internals can change within Linux in the future, while the protocol must not.
That's intentional, I see no point in recreating uapi values that won't change:
Linux errno: /include/uapi/asm-generic/errno{-base,}.h Pixel formats: include/uapi/drm/drm_fourcc.h Connector types and status: include/uapi/drm/drm_mode.h
Quoted 8 lines
Quoted 3 lines
If the device transfer buffer can't fit an uncompressed framebuffer update, the update is split up into parts that do fit.
Does "device transfer buffer" refer to something like display RAM on the device side? If so, its size is a device implementation detail which shouldn't be exposed over USB.
The reason for exposing this is that the Linux gadget driver needs to decompress the transfer into a buffer and the host needs to know how big this is (the host can choose to lower this if it can't allocate a continuous buffer of this size).
lz4 (in the kernel) is block compression and can't be used for decompressing just a stream of bytes. There is a lz4 frame protocol which looks like it could be useful, but it's not available in the kernel. I hardly know anything about compression so I'm in no position to add that to the kernel. Maybe someone will add it at a later time if it is useful.
Quoted 15 lines
It's true that the host drives USB communication but the device decides whether it will accept data or not. If not, it responds with a NAK handshake in the OUT transaction, and the host controller will then try to resend the data later, until the transfer timeout given by the host software expires. Retries are invisible to host software.
The point is: USB has native flow control on the lowest level; that's far more efficient than anything the application can construct, and flow control in the application protocol would be redundant.
When using gadgetfs IIRC device controllers NAK as long as the userspace process doesn't write new data to the ep?out-bulk fd. Have you tried/seen this?
Quoted 6 lines
Quoted 3 lines
The driver supports a one bit monochrome transfer format: R1. This is not implemented in the gadget driver. It is added in preparation for future monochrome e-ink displays.
The R1 idea is great!
My plan was to remove R1 support from this version of the patchset, but I forgot. The reason is that it's cumbersome to test when the gadget driver doesn't support it. I had some code to test the implementation when I made it, but it's removed now. It's very easy to add R1 back in when there's a display that makes use of it giving it a thorough testing.
You mention further down that you have use cases for this, do you have a timeplan for when you will make use of R1?
Quoted 6 lines
Quoted 2 lines
- Use donated Openmoko USB pid
If Linux will be the reference for this protocol then perhaps a PID under the Linux Foundation VID (1d6b) makes more sense?
Do they hand out pid's? To me it's no big deal, it can be added later if someones cares about it.
Quoted 2 lines
But: A PID applies on device level, not to interfaces.
Indeed. This is a USB interface driver though, so it only looks at vendor class interfaces. Then it checks if there's a bulk out endpoint, if not it returns -ENXIO and the device subsytem moves on to another interface driver if any. Next it tries to fetch the display descriptor and if not succesful it returns -ENODEV to give another driver a chance.
I have tried my best to let the driver tolerate other vendor class interfaces on the device.
Quoted 3 lines
Until this protocol becomes a USB-IF device class maybe it's better to create a probe for GUD interface(s) rather than binding to PID?
Not sure what you mean here, this is an interface driver.
There exists a HID Display page:
Request #: HUTRR29
Title: Repurposing the Alphanumeric Display Page (0x14) as a generic Auxiliary Display Page and adding bitmap and custom segment capabilities
https://www.usb.org/sites/default/files/hutrr29b_0.pdf
I couldn't find anything that uses it. It could have been interesting if there was a bulk endpoint here.
Quoted 3 lines
Does the driver btw. already support a composite device with multiple GUD interfaces? Say a microcontroller with two independent panels. It seems no?
I haven't tried, but it should work.
Quoted 6 lines
If yes, would any of the control requests currently sent to the interface be better directed at the device? If so, then a PID might make sense again, but it's still not possible to create a composite device which uses this protocol, without risking collissions with other vendor specific requests on other (vendor specific) interfaces, that would be a real shame.
I don't understand why PID should not be necessary, I'm using a vendor class interface and the driver can't probe all of those, so it has to look at specific vid:pid's.
Quoted 3 lines
I can imagine a composite device wanting to implement HID and GUD, let's make sure that it's possible.
I have tried together with a HID interface and that worked. I specifically want HID to work so it's possible to make touch displays. The Raspberry Pi images I've made available for testing has a console on a USB ACM (serial) interface.
Quoted 4 lines
On to the code.
Quoted 10 lines
drivers/gpu/drm/gud/gud_drm_drv.c line 45
Quoted 5 lines
drivers/gpu/drm/gud/gud_drm_drv.c new file +5
-0+static int gud_drm_usb_control_msg (struct usb_device *usb,u8 ifnum,bool in, +u8 request,u16 value,void *buf,size_t len, +bool check_len) +{ +u8 requesttype =USB_TYPE_VENDOR |USB_RECIP_INTERFACE ;This takes struct
usb_devicerather than structusb_interface- again, would this actually work with a composite device? The driver doesn't ever claim the interface so I guess no?
usb_interface has a pointer to usb_device and that's what's used to send usb messages, so instead of dereferencing each time I just use it directly.
Quoted 14 lines
Quoted 4 lines
drivers/gpu/drm/gud/gud_drm_drv.c new file +3
-0+static int gud_get_vendor_descriptor (struct usb_interface *interface, +struct gud_drm_display_descriptor *desc) +{..
drivers/gpu/drm/gud/gud_drm_drv.c line 83
Quoted 2 lines
drivers/gpu/drm/gud/gud_drm_drv.c new file +2
-0+ ret =gud_drm_usb_control_msg (usb, ifnum, true,USB_REQ_GET_DESCRIPTOR , +GUD_DRM_USB_DT_DISPLAY <<8 , buf,sizeof (*desc), false);
GUD_DRM_USB_DT_DISPLAYis defined as (USB_TYPE_VENDOR|0x4), butUSB_TYPE_VENDORonly applies to bmRequestType[6:5] in control transfers, nowhere else. I know of no standardized way to introduce vendor-specific descriptors. Squatting is possible, but I think it would be nice to do better here. It is easy enough.
Quoted 6 lines
It could be argued that the vendor specific interface gives flexibility here, but actually it just means that the semantics of the standardized and well-defined
USB_REQ_GET_DESCRIPTORhave been duplicated by this protocol, that is not very common - but if you want to go ahead then at least dropUSB_TYPE_VENDORfrom theGUD_DRM_USB_DT_DISPLAYdefinition.
I liked that it is well defined and understood, so I didn't have to be clever. It's nice that the size is embedded for future versions of the protocol that migh expand the descriptor. Well not so important now that I have the version number in there.
I like it and think I'll keep it, so I'll change the macro:
#define GUD_DRM_USB_DT_DISPLAY 0x44
Quoted 6 lines
Maybe it's good to think about the data exchange some more - anything not transfered by standardized
USB_REQ_GET_DESCRIPTOR(bmRequestType 10000000B; Device-to-host data, Standard type, Device recipient) isn't actually a descriptor, it's vendor-specific, free-format data. Does that enable any simplifications?
Actually it is:
u8 requesttype = USB_TYPE_VENDOR | USB_RECIP_INTERFACE;
see gud_drm_usb_control_msg(). I could add GUD_DRM_USB_REQ_GET_DESCRIPTOR instead of using USB_REQ_GET_DESCRIPTOR if that makes it any clearer.
Quoted 16 lines
drivers/gpu/drm/gud/gud_drm_drv.c line 120
Quoted 13 lines
drivers/gpu/drm/gud/gud_drm_drv.c new file +12
-0+static int gud_usb_get_status (struct usb_device *usb,u8 ifnum) +{ +struct gud_drm_req_get_status *status; +int ret, status_retries =2000 /5 ;/* maximum wait ~2 seconds */ +unsigned long delay =500 ; + + status =kmalloc (sizeof (*status),GFP_KERNEL ); +if (!status) +return -ENOMEM ; + +/* +* Poll due to lack of data/status stage control on the gadget side. I hope we can find something better here.
Quoted 3 lines
Doesn't gadgetfs allow userspace to (indirectly) control the status stage, as I wrote above?
For read requests the device is stalling in case of error and the host issues a status request.
For write requests the only thing I've found is a way to delay the status stage, but only for requests without payload:
drivers/usb/gadget/composite.c: composite_setup():
} else if (value == USB_GADGET_DELAYED_STATUS && w_length != 0) {
WARN(cdev,
"%s: Delayed status not supported for w_length != 0",
__func__);
}And I can't stall, only continue:
/**
* usb_composite_setup_continue() - Continue with the control transfer
* @cdev: the composite device who's control transfer was kept waiting *
* This function must be called by the USB function driver to continue
* with the control transfer's data/status stage in case it had requested to
* delay the data/status stages. A USB function's setup handler (e.g.set_alt())
* can request the composite framework to delay the setup request's
data/status
* stages by returning USB_GADGET_DELAYED_STATUS.
*/
void usb_composite_setup_continue(struct usb_composite_dev *cdev)
If I could control the status stage and stall after data was received, then I wouldn't need my own status stage.
Quoted 8 lines
drivers/gpu/drm/gud/gud_drm_drv.c line 125
Quoted 5 lines
drivers/gpu/drm/gud/gud_drm_drv.c new file +4
-0+* If we did not use polling and gave up here after waiting 2 seconds, +* the worker in the gadget would finally get to queuing up the status +* respons, but by that time the host has moved on. The gadget side +* (at least dwc2) would now be left in a non-recoverable state. Independently of the above, how does the gadget become non-recoverable?
It stops responding to requests.
Quoted 5 lines
If a transfer times out on the host without other error then the device has replied with NAK in the data stage transactions sent by the host until the host stopped trying. The device controller then sees no further data stage transactions and shouldn't be in a weird state?
I don't know why it doesn't respond, it could be a controller driver (dwc2) bug, but I'm no expert here. Actually this is the first work I've ever done with USB.
Quoted 24 lines
drivers/gpu/drm/gud/gud_drm_drv.c line 132
Quoted 7 lines
drivers/gpu/drm/gud/gud_drm_drv.c new file +6
-0+* Worst case commit timeout in DRM can be tens of seconds (wait for +* various _done completions). +*/ +while (status_retries--) { + ret =gud_drm_usb_control_msg (usb, ifnum, true,USB_REQ_GET_STATUS ,0 , + status,sizeof (*status), true);Instead of this loop a single request with 2000 ms timeout would avoid software overhead on the host. The header file says that 0 == PENDING is the only exit condition for the loop besides timeout, as long as there are no other conditions it's better to just wait for the timeout.
drivers/gpu/drm/gud/gud_drm_drv.c line 137
Quoted 2 lines
drivers/gpu/drm/gud/gud_drm_drv.c new file +2
-0+if (!(status->flags &GUD_DRM_STATUS_PENDING )) { + ret = -status->errno;So this exposes errno (an implementation detail) in the bus protocol, at an absolute minimum it needs some
le_to_cpu()adjustment, but I think it would be cleaner to define the specific errors that are application relevant.
Quoted 4 lines
If this
get_statusthing is in fact really really required then how about adding an interrupt IN endpoint for it? I think that would be cleaner and it costs less bus time with arguably lower latency. See e.g. usblp.
I couldn't find interrupt ep used in drivers/usb/class/usblp.c, but I've seen examples of this used for status.
I'm a bit wary of using more endpoints since I suspect that microcontrollers don't have that many.
I did a test setting delay to fixed 500-1500 usec in the polling loop instead of the 4500-5500 that will be used when running a movie. Actual frames per second for a 30 sec movie clip changed from 8.8 to 9.0, so latency isn't a big issue at least.
I also realise now that I don't need the PENDING flag, I can just keep stalling the status request until the device is done.
Quoted 6 lines
Quoted 5 lines
drivers/gpu/drm/gud/gud_drm_drv.c new file +4
-0+static struct drm_gem_object * +gud_drm_driver_gem_create_object (struct drm_device *dev,size_t size) +{ +struct drm_gem_shmem_object *shmem;..
Quoted 9 lines
drivers/gpu/drm/gud/gud_drm_drv.c line 295
Quoted 6 lines
drivers/gpu/drm/gud/gud_drm_drv.c new file +6
-0+/* +* This doesn't make a difference on x86, but on ARM (pi4) it was +* necessary to avoid black lines all over and it made it possible to +* compress directly from the framebuffer without performance drop. +*/ + shmem->map_cached = true;Can you explain what this does exactly?
Not excatly, but I can try rather vaguely :-) The memory subsystem is a black box to me. It has to do with the memory page attribute that controls how memory access is handled by the CPU cache. The default for shmem is WriteCombined which makes for slow read access on ARM, but on x86 there doesn't seem to be any penalty judging by my brief testing. The black lines are probably cache lines that haven't been flushed/invalidated or whatever the black box does.
Quoted 7 lines
Quoted 4 lines
drivers/gpu/drm/gud/gud_drm_drv.c new file +3
-0+static int gud_drm_probe (struct usb_interface *interface, +const struct usb_device_id *id) +{..
Quoted 1 line
drivers/gpu/drm/gud/gud_drm_drv.c new file +1
-0+struct gud_drm_display_descriptor desc;..
Quoted 14 lines
drivers/gpu/drm/gud/gud_drm_drv.c line 430
Quoted 10 lines
drivers/gpu/drm/gud/gud_drm_drv.c new file +10
-0+/* Check if the device can support us */ + *version =1 ; + ret =gud_drm_usb_control_msg (usb, ifnum, false,GUD_DRM_USB_REQ_SET_VERSION , +0 , version,sizeof (*version), true); +if (!ret) + ret =gud_usb_get_status (usb, ifnum); +kfree (version); +if (ret) { +dev_err (dev,"Protocol version %u is not supported\n" , desc.bVersion); +return -EPROTONOSUPPORT ;Could't this work without
_get_status()? What doesusb_control_msg()return for a STALL handshake in the data stage?
It returns -EPIPE, but as mentioned above, I can't stall a control write request with payload. So I need my own status stage.
Quoted 11 lines
Anyway,
usb_get_status()(which I guess inspiredgud_usb_get_status()) is usually for administrative device status rather than application status. Ideally the application status can be deduced by host software based on device responses...
drivers/gpu/drm/gud/gud_drm_drv.c line 451
Quoted 1 line
drivers/gpu/drm/gud/gud_drm_drv.c new file +1
-0+ gdrm->compression = desc.bCompression &GUD_DRM_COMPRESSION_LZ4 ;This is a perfect example of doing things right! :)
Quoted 6 lines
GUD_DRM_COMPRESSION_LZ4is specific for this protocol, not DRM/Linux.What do you think about s,GUD_DRM_,GUD_, for such names?
And would it make sense to expose the protocol (names, structures) in uapi?
No, since it's not for userspace.
Quoted 2 lines
Or at least in
Documentation/?
Ideally I would have written a spec and made the implementation against it. However since I suck at writing, I even struggle with getting the compiler to understand me, so it won't happen. It would have taken me forever.
Quoted 14 lines
Quoted 5 lines
drivers/gpu/drm/gud/gud_drm_pipe.c new file +4
-0+static size_t gud_drm_xrgb8888_to_r124 (u8 *dst,const struct drm_format_info *format, +void *src,struct drm_framebuffer *fb, +struct drm_rect *rect) +{..
drivers/gpu/drm/gud/gud_drm_pipe.c line 56
Quoted 3 lines
drivers/gpu/drm/gud/gud_drm_pipe.c new file +3
-0+ buf =kmalloc (width * height,GFP_KERNEL ); +if (!buf) +return len;/* To keep logic simple, just transmit garbage */ Ouch! Shouldn't this bubble up somehow? If there is memory pressure then I really think something above should fail.
Quoted 6 lines
drivers/gpu/drm/gud/gud_drm_pipe.c line 80
Quoted 3 lines
drivers/gpu/drm/gud/gud_drm_pipe.c new file +3
-0+static int gud_drm_fb_flush (struct gud_drm_device *gdrm,struct drm_framebuffer *fb, +const struct drm_format_info *format,struct drm_rect *rect) +{This is in the hot path, right?
Indeed, the most important one. All the other paths can take "as long" as they want, but this one "shows up" on the display.
Quoted 20 lines
drivers/gpu/drm/gud/gud_drm_pipe.c line 176
Quoted 7 lines
drivers/gpu/drm/gud/gud_drm_pipe.c new file +6
-0+ ret =gud_drm_usb_set (gdrm,GUD_DRM_USB_REQ_SET_BUFFER ,0 , &req,sizeof (req)); +if (ret) + goto vunmap; + + ret =usb_bulk_msg (gdrm->usb, gdrm->bulk_pipe, gdrm->bulk_buf, trlen, + &actual_length,msecs_to_jiffies (3000 ));I would definitely change this pattern so that the hot path has only bulk transactions, ideally a single transfer. The control transfer wastes precious bus time in the hot path.
Maybe it's insignificant with FHD data but then again, the more data the less overhead we want, and in any case for small R1 data the control transfer is easily more expensive than the data itself!
A control transfer somehow compares to an
ioctl()from userspace with much context switching, while a bulk transfer is more like mmaped kernel memory or aio.
Quoted 7 lines
Why not just add the values in struct
gud_drm_req_set_bufferas a header before the data instead?That would mean two bulk transfers, but they could be asynchronous, at least the first, but making both async would also fit more data onto the bus. Maybe later.
GUD_DRM_USB_REQ_SET_BUFFER serves one purpose in addition to sending the header, as mentioned in the comment preceeding it, it waits for any ongoing decompression/copying on the device from the previous fb flush. lz4 decompression is much faster than compression, but the host will be much more powerful than the device, so the host will almost always have to wait for the device when flushing continously.
Yes you're right, the overhead is insignificant for FHD, 4-500 usec for the actual control messages (including status message) vs. 50-100ms for the total operation (depending on how well it compresses).
But why should this overhead be of concern for a display that has a framebuffer transfer of 4-8kB? It will be more than fast enough.
Quoted 14 lines
include/drm/gud_drm.h line 112
Quoted 8 lines
+ * struct
gud_drm_req_get_connector- Connector descriptor
+ * @connector_type: Connector type (DRM_MODE_CONNECTOR_*)
+ * @flags: Flags
+ * @num_properties: Number of supported properties
+ */include/drm/gud_drm.h new file +2
-0+struct gud_drm_req_get_connector { +__u8 connector_type;This is intended for the (Generic) USB Display to report the connector type used for its panel, right? It should not use Linux/DRM-internal values such as
DRM_MODE_CONNECTOR_SPIto do so, if it wants to be generic and stable over time.
DRM_MODE_CONNECTOR_SPI is uabi from include/uapi/drm/drm_mode.h
Quoted 7 lines
Why does the host software need to know anything about the connector inside the device, anyway? With a microcontroller that could be anything, especially with actual R1 displays.
Would it make sense to introduce
DRM_MODE_CONNECTOR_USBon the host, and keep this implementation detail in the device?
For display adapters it makes sense especially when it has more than one connector like the Raspberry Pi which has an hdmi and a sdtv connector. For display panels the connector is USB yes, but there's no type for this yet. There's a discussion going on if we should stop adding connector types for panels and just add a DRM_MODE_CONNECTOR_PANEL type. Not sure if there has been a conclusion on this.
Quoted 7 lines
Make the protocol application specific and avoid implementation specifics.
Quoted 1 line
+ * struct
gud_drm_req_get_connector_status- Connector statusHow does this work if and when the status on the device changes?
If that status can change, the device has to set gud_drm_gadget_connector.flags |= GUD_DRM_CONNECTOR_FLAGS_POLL. Now the host will poll the status every 10 seconds. Userspace is notified about change in status.
Quoted 11 lines
include/drm/gud_drm.h line 189
Quoted 6 lines
include/drm/gud_drm.h new file +5
-0+/* +* Internal monochrome transfer format presented to userspace as XRGB8888. +* Pixel lines are byte aligned. +*/ +#define GUD_DRM_FORMAT_R1 fourcc_code('R', '1', ' ', ' ')This is also a data format over USB, right? Then it's not really internal, because it also exists on the device. I have several uses for this, but none will be using Linux gadgets, rather microcontrollers.
I can drop the word internal if it confuses, but any non-Linux implementation will have to copy this header file and resolve the dependencies. Like I did for my uC hack:
https://github.com/notro/gud/tree/master/STM32F769I-DISCO/USB_Device/MSC_Standalone/Inc
Quoted 25 lines
include/drm/gud_drm.h line 237
Quoted 10 lines
include/drm/gud_drm.h new file +9
-0+/* USB Control requests: */ + +/* +* If the host driver doesn't support the device protocol version it will send +* the versions it supports starting with the latest. If the device isn't +* backwards compatible or doesn't support the version the host suggests, it +* shall return EPROTONOSUPPORT. +*/ +#define GUD_DRM_USB_REQ_SET_VERSION 0x30USB devices report errors to a control requests with a STALL handshake, which is passed all the way back to the host software. Please use that?
How/where would the EPROTONOSUPPORT value be returned? It's another implementation specific, that should be used on the bus.
include/drm/gud_drm.h line 240
Quoted 2 lines
include/drm/gud_drm.h new file +2
-0+/* Get supported pixel formats as an array of fourcc codes. See include/uapi/drm/drm_fourcc.h */ +#define GUD_DRM_USB_REQ_GET_FORMATS 0x40Plus R1, right? I can understand if you don't want to add R1 to uapi, but then at least document that the array can contain both uapi codes and R1.
Quoted 9 lines
include/drm/gud_drm.h line 275
Quoted 2 lines
include/drm/gud_drm.h new file +2
-0+/* Apply the prevoius _STATE_CHECK configuration */ +#define GUD_DRM_USB_REQ_SET_STATE_COMMIT 0x62Typo -> previous
I hope this helps.
Indeed it I does, it helps me revisit the decisions I've made and look at them in a new light. I have looked at the code for so long that I hardly see it anymore.
Noralf.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 4/6] drm: Add Generic USB Display driver
Hi Noralf,
Thanks a lot for going into more detail.
Quoted 6 lines · Noralf Trønnes
Quoted 5 lines
Several Linux/DRM internals have "leaked" into the USB protocol - this should be avoided if you want device implementations other than your gadget, because those internals can change within Linux in the future, while the protocol must not.
Quoted 6 lines
That's intentional, I see no point in recreating uapi values that won't change:
Linux errno: /include/uapi/asm-generic/errno{-base,}.h Pixel formats:
include/uapi/drm/drm_fourcc.hConnector types and status:include/uapi/drm/drm_mode.h
I understand, and it's good that these are uapi values, but I will still disagree with using errno and DRM connector types in the USB protocol, which is a "namespace" of its own.
That is an important point here; GUD is three things: a Linux DRM driver, a Linux gadget driver and a USB protocol. USB protocols (good ones) are OS-agnostic.
Quoted 11 lines
Quoted 6 lines
Quoted 2 lines
If the device transfer buffer can't fit an uncompressed framebuffer update, the update is split up into parts that do fit.
Does "device transfer buffer" refer to something like display RAM on the device side? If so, its size is a device implementation detail which shouldn't be exposed over USB.
The reason for exposing this is that the Linux gadget driver needs to decompress the transfer into a buffer and the host needs to know how big this is (the host can choose to lower this if it can't allocate a continuous buffer of this size).
I understand; so it's only required for some compression types - then it should at least be completely optional, but in any case I find exposing/having to expose this to be awful USB protocol design and I hope we can find a better way.
Maybe it's premature anyway? How would you feel about skipping compression to begin with?
Quoted 6 lines
lz4 (in the kernel) is block compression and can't be used for decompressing just a stream of bytes. There is a lz4 frame protocol which looks like it could be useful, but it's not available in the kernel. I hardly know anything about compression so I'm in no position to add that to the kernel. Maybe someone will add it at a later time if it is useful.
Why did you choose to use lz4?
Whether compression comes now or later, maybe there is a more suitable algorithm?
Quoted 5 lines
Quoted 1 line
The R1 idea is great!
My plan was to remove R1 support from this version of the patchset, but I forgot. The reason is that it's cumbersome to test when the gadget driver doesn't support it.
Why not support R1 also in the gadget?
Quoted 2 lines
You mention further down that you have use cases for this, do you have a timeplan for when you will make use of R1?
No strict plan, but if it helps I could make a demo device and -firmware without much effort. You mentioned that you would like to have a microcontroller device for testing?
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
- Use donated Openmoko USB pid
If Linux will be the reference for this protocol then perhaps a PID under the Linux Foundation VID (1d6b) makes more sense?
Do they hand out pid's?
I don't know. :) The root hub drivers each have one.
Quoted 1 line
To me it's no big deal, it can be added later if someones cares about it.
Okay, hopefully we can do without a PID anyway.
Quoted 7 lines
Quoted 1 line
But: A PID applies on device level, not to interfaces.
Indeed. This is a USB interface driver though, so it only looks at vendor class interfaces. Then it checks if there's a bulk out endpoint, if not it returns
-ENXIOand the device subsytem moves on to another interface driver if any. Next it tries to fetch the display descriptor and if not succesful it returns-ENODEVto give another driver a chance.
Thanks for clarifying this flow. It's nice not to require particular endpoint addresses - that makes the protocol/driver much more generic.
Quoted 2 lines
I have tried my best to let the driver tolerate other vendor class interfaces on the device.
Ack, this is clear now.
Quoted 3 lines
I don't understand why PID should not be necessary, I'm using a vendor class interface and the driver can't probe all of those, so it has to look at specific vid:pid's.
Why can't the driver probe all vendor class interfaces?
To probe fewer interfaces, a criteria other than PID can still be defined, and doing so would enable immediate plug-and-play for non-gadget and especially composite devices, without requiring the addition of PIDs in the host driver.
I find this possibility especially attractive for composite devices, which may already have some VID:PID and a non-GUD primary function/interface that is handled by another driver, such that a GUD PID effectively can't be adopted for that device.
One example of such a criteria would be to require that the iInterface string descriptor contains the (sub)string "Generic USB Display".
Quoted 1 line
I have tried together with a HID interface and that worked.
Great. Thanks!
Quoted 13 lines
Quoted 13 lines
Quoted 3 lines
drivers/gpu/drm/gud/gud_drm_drv.c new file +3
-0+static int gud_get_vendor_descriptor (struct usb_interface *interface, +struct gud_drm_display_descriptor *desc) +{..
drivers/gpu/drm/gud/gud_drm_drv.c line 83
Quoted 2 lines
drivers/gpu/drm/gud/gud_drm_drv.c new file +2
-0+ ret =gud_drm_usb_control_msg (usb, ifnum, true,USB_REQ_GET_DESCRIPTOR , +GUD_DRM_USB_DT_DISPLAY <<8 , buf,sizeof (*desc), false);
GUD_DRM_USB_DT_DISPLAYis defined as (USB_TYPE_VENDOR|0x4), butUSB_TYPE_VENDORonly applies to bmRequestType[6:5] in control transfers, nowhere else. I know of no standardized way to introduce vendor-specific descriptors. Squatting is possible, but I think it would be nice to do better here. It is easy enough.
Quoted 7 lines
Quoted 5 lines
It could be argued that the vendor specific interface gives flexibility here, but actually it just means that the semantics of the standardized and well-defined
USB_REQ_GET_DESCRIPTORhave been duplicated by this protocol, that is not very common - but if you want to go ahead then at least dropUSB_TYPE_VENDORfrom theGUD_DRM_USB_DT_DISPLAYdefinition.I liked that it is well defined and understood, so I didn't have to be clever.
I tried to explain that it is only well defined for the standardized GET_DESCRIPTOR request with device recipient. The concept "descriptor" isn't used anywhere else by other USB protocols that I know.
There are various class-specific descriptors, but they are all standardized in USB-IF device class specs, and all of them are only ever retrieved by the standardized GET_DESCRIPTOR request.
Because of that it's actually rather confusing to me to refer to the display data structure as a descriptor and even use the standardized descriptor header and naming convention when it is actually /not/ a descriptor, since it isn't standardized and isn't retrievable with the standardized GET_DESCRIPTOR request. Does that make sense?
Quoted 3 lines
I like it and think I'll keep it, so I'll change the macro:
#define
GUD_DRM_USB_DT_DISPLAY0x44
Okay. The number is arbitrary, since a control request directed to a vendor specific interface is vendor specific "by inheritance", thus also arbitrary.
Quoted 9 lines
Quoted 5 lines
Maybe it's good to think about the data exchange some more - anything not transfered by standardized
USB_REQ_GET_DESCRIPTOR(bmRequestType 10000000B; Device-to-host data, Standard type, Device recipient) isn't actually a descriptor, it's vendor-specific, free-format data. Does that enable any simplifications?Actually it is:
u8 requesttype = USB_TYPE_VENDOR | USB_RECIP_INTERFACE;
Right; it's a Vendor-Specific type, Interface recipient request, thus not the standardized USB_REQ_GET_DESCRIPTOR, and thus the data is not actually a descriptor, hence why calling it one is confusing to me.
Quoted 3 lines
see
gud_drm_usb_control_msg(). I could addGUD_DRM_USB_REQ_GET_DESCRIPTORinstead of usingUSB_REQ_GET_DESCRIPTORif that makes it any clearer.
That would be an improvement, but I would really wish for different terminology all together.
Quoted 15 lines
Quoted 15 lines
drivers/gpu/drm/gud/gud_drm_drv.c line 120
Quoted 12 lines
drivers/gpu/drm/gud/gud_drm_drv.c new file +12
-0+static int gud_usb_get_status (struct usb_device *usb,u8 ifnum) +{ +struct gud_drm_req_get_status *status; +int ret, status_retries =2000 /5 ;/* maximum wait ~2 seconds */ +unsigned long delay =500 ; + + status =kmalloc (sizeof (*status),GFP_KERNEL ); +if (!status) +return -ENOMEM ; + +/* +* Poll due to lack of data/status stage control on the gadget side. I hope we can find something better here.
Quoted 5 lines
Quoted 2 lines
Doesn't gadgetfs allow userspace to (indirectly) control the status stage, as I wrote above?
For read requests the device is stalling in case of error and the host issues a status request.
Sorry, I can't quite understand this.
Does read mean IN or OUT?
And what does "the host issues a status request" mean? Status is the final stage in each (control request) transaction. I'm a bit confused here.
Quoted 2 lines
For write requests the only thing I've found is a way to delay the status stage, but only for requests without payload:
..
Quoted 1 line
drivers/usb/gadget/composite.c:composite_setup():
The way I read composite_setup() after try_fun_setup: it calls f->setup() when available, and that can return < 0 to stall.
I expect that composite_setup() and thus f->setup() run when the SETUP packet has arrived, thus before the data packet arrives, and if composite_setup() stalls then the device/function should never see the data packet.
For an OUT transaction I think the host controller might still send the DATA packet, but the device controllers that I know don't make it visible to the application in that case.
Quoted 1 line
And I can't stall, only continue:
..
Quoted 2 lines
If I could control the status stage and stall after data was received, then I wouldn't need my own status stage.
It looks to me like the function can stall.
In any case I think the delayed thing+continue is the wrong path.
Quoted 9 lines
Quoted 6 lines
drivers/gpu/drm/gud/gud_drm_drv.c line 125
Quoted 4 lines
drivers/gpu/drm/gud/gud_drm_drv.c new file +4
-0+* If we did not use polling and gave up here after waiting 2 seconds, +* the worker in the gadget would finally get to queuing up the status +* respons, but by that time the host has moved on. The gadget side +* (at least dwc2) would now be left in a non-recoverable state. Independently of the above, how does the gadget become non-recoverable?
It stops responding to requests.
Quoted 7 lines
Quoted 4 lines
If a transfer times out on the host without other error then the device has replied with NAK in the data stage transactions sent by the host until the host stopped trying. The device controller then sees no further data stage transactions and shouldn't be in a weird state?
I don't know why it doesn't respond, it could be a controller driver (dwc2) bug, but I'm no expert here.
It would be useful to investigate this in more detail.
And I think it would be useful to have another, independent, device implementation. I could help with that.
Quoted 1 line
Actually this is the first work I've ever done with USB.
I think it's a very ambitious first USB project, but it is a fun idea! :)
I would like it if we can iterate to something really generic that takes advantage of all that USB offers.
Quoted 6 lines
Quoted 3 lines
If this
get_statusthing is in fact really really required then how about adding an interrupt IN endpoint for it? I think that would be cleaner and it costs less bus time with arguably lower latency. See e.g. usblp.I couldn't find interrupt ep used in
drivers/usb/class/usblp.c, but I've seen examples of this used for status.
Sorry, yes, in usblp it is a bulk endpoint, it was more about the pattern of a status endpoint.
Quoted 2 lines
I'm a bit wary of using more endpoints since I suspect that microcontrollers don't have that many.
It was true for some early microcontrollers with USB, but I haven't seen one in many years with less than six endpoints, and usually they have more. Some really old 8-bit ones even allowed using all 32 possible endpoints, more than many modern IP blocks.
To me it is critical to remove this status polling, because as I wrote, the lowest level protocol already implements very good flow control, the application protocol just needs to use it, not invent its own.
Quoted 2 lines
I also realise now that I don't need the PENDING flag, I can just keep stalling the status request until the device is done.
That's heading in the right direction, but the transaction should be NAKed rather than STALLed.
Think of NAK as EAGAIN and STALL more like EPIPE. The former is "not yet" while the latter signals that there was an actual error.
It looks like composite_setup() might indeed not support NAK, that would be a bug/missing feature in the gadget code, but I may also just be reading it wrong. Either way it doesn't justify polling in the application protocol.
In addition to being redundant, such polling generates constant application- level noise on the bus, causes unneccessary wakeups and is very annoying when looking at packet captures e.g. from usbmon. We should avoid that.
Quoted 9 lines
Quoted 3 lines
drivers/gpu/drm/gud/gud_drm_drv.c line 295
Quoted 1 line
drivers/gpu/drm/gud/gud_drm_drv.c new file +1
-0+ shmem->map_cached = true;Can you explain what this does exactly?
Not excatly, but I can try rather vaguely :-) The memory subsystem is a black box to me. It has to do with the memory page attribute that controls how memory access is handled by the CPU cache. The default for shmem is WriteCombined which makes for slow read access on ARM, but on x86 there doesn't seem to be any penalty judging by my brief testing.
Hmm. ARM often (always?) can't do byte-aligned access, only 32-bit access. Do you know if and how the buffer is aligned? Maybe this can make a difference?
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/gud/gud_drm_drv.c new file +3
-0+static int gud_drm_probe (struct usb_interface *interface, +const struct usb_device_id *id) +{
..
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/gud/gud_drm_drv.c line 424
Quoted 4 lines
drivers/gpu/drm/gud/gud_drm_drv.c new file +4
-0+/* Check if the device can support us */ + *version =1 ; + ret =gud_drm_usb_control_msg (usb, ifnum, false,GUD_DRM_USB_REQ_SET_VERSION , +0 , version,sizeof (*version), true);
A more USB:y way would btw. be to report the highest supported protocol version to the host in some data structure.
This too could be the iInterface string descriptor.
Quoted 5 lines
Quoted 2 lines
Could't this work without
_get_status()? What doesusb_control_msg()return for a STALL handshake in the data stage?It returns
-EPIPE, but as mentioned above, I can't stall a control write request with payload.
Please check this? It looks to me like it would be possible.
Quoted 3 lines
Quoted 1 line
And would it make sense to expose the protocol (names, structures) in uapi?
No, since it's not for userspace.
Okay.
Quoted 5 lines
Quoted 1 line
Or at least in
Documentation/?Ideally I would have written a spec and made the implementation against it. However since I suck at writing, I even struggle with getting the compiler to understand me, so it won't happen. It would have taken me forever.
I have a template for USB protocols that I could use, perhaps we can make that spec a reality. I think it would be quite valuable, to help folks outside Linux who may also want to create a generic usb display.
Quoted 11 lines
Quoted 11 lines
Quoted 4 lines
drivers/gpu/drm/gud/gud_drm_pipe.c new file +4
-0+static size_t gud_drm_xrgb8888_to_r124 (u8 *dst,const struct drm_format_info *format, +void *src,struct drm_framebuffer *fb, +struct drm_rect *rect) +{..
drivers/gpu/drm/gud/gud_drm_pipe.c line 56
Quoted 3 lines
drivers/gpu/drm/gud/gud_drm_pipe.c new file +3
-0+ buf =kmalloc (width * height,GFP_KERNEL ); +if (!buf) +return len;/* To keep logic simple, just transmit garbage */ Ouch! Shouldn't this bubble up somehow? If there is memory pressure then I really think something above should fail.
No comment on this?
Quoted 32 lines
Quoted 5 lines
drivers/gpu/drm/gud/gud_drm_pipe.c line 80
Quoted 3 lines
drivers/gpu/drm/gud/gud_drm_pipe.c new file +3
-0+static int gud_drm_fb_flush (struct gud_drm_device *gdrm,struct drm_framebuffer *fb, +const struct drm_format_info *format,struct drm_rect *rect) +{This is in the hot path, right?
Indeed, the most important one. All the other paths can take "as long" as they want, but this one "shows up" on the display.
Quoted 23 lines
drivers/gpu/drm/gud/gud_drm_pipe.c line 176
Quoted 7 lines
drivers/gpu/drm/gud/gud_drm_pipe.c new file +6
-0+ ret =gud_drm_usb_set (gdrm,GUD_DRM_USB_REQ_SET_BUFFER ,0 , &req,sizeof (req)); +if (ret) + goto vunmap; + + ret =usb_bulk_msg (gdrm->usb, gdrm->bulk_pipe, gdrm->bulk_buf, trlen, + &actual_length,msecs_to_jiffies (3000 ));I would definitely change this pattern so that the hot path has only bulk transactions, ideally a single transfer. The control transfer wastes precious bus time in the hot path.
Maybe it's insignificant with FHD data but then again, the more data the less overhead we want, and in any case for small R1 data the control transfer is easily more expensive than the data itself!
A control transfer somehow compares to an
ioctl()from userspace with much context switching, while a bulk transfer is more like mmaped kernel memory or aio.Why not just add the values in struct
gud_drm_req_set_bufferas a header before the data instead?
Quoted 7 lines
Quoted 3 lines
That would mean two bulk transfers, but they could be asynchronous, at least the first, but making both async would also fit more data onto the bus. Maybe later.
GUD_DRM_USB_REQ_SET_BUFFERserves one purpose in addition to sending the header, as mentioned in the comment preceeding it, it waits for any ongoing decompression/copying on the device from the previous fb flush.
So even more application-level flow control. Please let's make sure that the protocol will simply rely on the low-level flow control here as well.
Quoted 3 lines
lz4 decompression is much faster than compression, but the host will be much more powerful than the device, so the host will almost always have to wait for the device when flushing continously.
One design objective for USB is indeed strong host+weak device and the low-level flow control applies particularly well in this case. The device explicitly informs the host that it is not ready for data using NAK.
Quoted 6 lines
Yes you're right, the overhead is insignificant for FHD, 4-500 usec for the actual control messages (including status message) vs. 50-100ms for the total operation (depending on how well it compresses).
But why should this overhead be of concern for a display that has a framebuffer transfer of 4-8kB? It will be more than fast enough.
Mm, insignificant there as well, but in both cases it's not optimal, and that without good reason.
Besides that, it also causes unneccessary synchronization/bus scheduling complexity and wastes bandwidth. Control transfers and bulk transfers are scheduled to wire time according to different rules, with control requests taking priority over bulk in case of contention.
A control request occupies more bus time than a NAKed bulk data transaction.
Finally, besides application level flow control simply being wrong it's doubly wrong to use the control pipe to implement flow control for a bulk pipe; those two pipes are completely independent bus channels, and shouldn't be interlocked without an exceptionally good reason and flow control isn't it.
Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
+ * struct
gud_drm_req_get_connector- Connector descriptor
+ * @connector_type: Connector type (DRM_MODE_CONNECTOR_*)
+ * @flags: Flags
+ * @num_properties: Number of supported propertiesQuoted 8 lines
include/drm/gud_drm.h line 112
Quoted 3 lines
+ */
include/drm/gud_drm.h new file +2
-0+struct gud_drm_req_get_connector { +__u8 connector_type;This is intended for the (Generic) USB Display to report the connector type used for its panel, right? It should not use Linux/DRM-internal values such as
DRM_MODE_CONNECTOR_SPIto do so, if it wants to be generic and stable over time.
Quoted 1 line
DRM_MODE_CONNECTOR_SPIis uabi frominclude/uapi/drm/drm_mode.h
Sorry - that wasn't clear to me, and that's better than internal values, but it's still not great to declare that this USB protocol value is locked to anything else.
It would be better to define these values independently. As long as it is possible they can of course use the same values as the uapi, but I will argue that they should be able to diverge, because this USB protocol idea doesn't inherently have anything to do with Linux.
Quoted 9 lines
Quoted 6 lines
Why does the host software need to know anything about the connector inside the device, anyway? With a microcontroller that could be anything, especially with actual R1 displays.
Would it make sense to introduce
DRM_MODE_CONNECTOR_USBon the host, and keep this implementation detail in the device?For display adapters it makes sense especially when it has more than one connector like the Raspberry Pi which has an hdmi and a sdtv connector.
Right, a GUD device could have multiple connectors, I guess with one USB interface per connector, but again, what does the host really need to know about the connector beyond the supported pixel format(s)?
Thanks for mentioning SDTV - I wasn't sure about the rationale for those TV parts in the patch. Can you elaborate on that?
If the idea is in fact to create "Linux DRM over USB" then by all means go for it, but in that case please don't call it generic.
Quoted 4 lines
For display panels the connector is USB yes, but there's no type for this yet. There's a discussion going on if we should stop adding connector types for panels and just add a
DRM_MODE_CONNECTOR_PANELtype. Not sure if there has been a conclusion on this.
Ack. That does sound like it could be useful for the DRM GUD driver.
Quoted 10 lines
Quoted 6 lines
Make the protocol application specific and avoid implementation specifics.
Quoted 1 line
+ * struct
gud_drm_req_get_connector_status- Connector statusHow does this work if and when the status on the device changes?
If that status can change, the device has to set gud_drm_gadget_connector.flags |=
GUD_DRM_CONNECTOR_FLAGS_POLL. Now the host will poll the status every 10 seconds.
I understand - this is another place where the application requirements call for an interrupt status endpoint. I think it should be one and the same endpoint for all status changes.
Quoted 11 lines
Quoted 9 lines
include/drm/gud_drm.h line 189
Quoted 5 lines
include/drm/gud_drm.h new file +5
-0+/* +* Internal monochrome transfer format presented to userspace as XRGB8888. +* Pixel lines are byte aligned. +*/ +#define GUD_DRM_FORMAT_R1 fourcc_code('R', '1', ' ', ' ')This is also a data format over USB, right? Then it's not really internal, because it also exists on the device. I have several uses for this, but none will be using Linux gadgets, rather microcontrollers.
I can drop the word internal if it confuses,
I think that would be a big improvement.
Quoted 3 lines
but any non-Linux implementation will have to copy this header file and resolve the dependencies. Like I did for my uC hack:
https://github.com/notro/gud/tree/master/STM32F769I-DISCO/USB_Device/MSC_Standalone/Inc
I think it would be better to document the value instead.
Quoted 5 lines
Quoted 1 line
I hope this helps.
Indeed it I does, it helps me revisit the decisions I've made and look at them in a new light. I have looked at the code for so long that I hardly see it anymore.
I know the feeling and I'm glad to help, but only if the goal is indeed to create a generic USB:y protocol, mostly if not completely free of Linux details.
If you're actually after something more closely tied to Linux/DRM then that's also a fun idea, but much less relevant for me.
Thanks and kind regards
//Peter
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 4/6] drm: Add Generic USB Display driver
On Tue, Jun 02, 2020 at 12:12:07AM +0000, Peter Stuge wrote:
...
Quoted 11 lines
The way I read
composite_setup()aftertry_fun_setup: it callsf->setup()when available, and that can return < 0 to stall.I expect that
composite_setup()and thusf->setup()run when the SETUP packet has arrived, thus before the data packet arrives, and ifcomposite_setup()stalls then the device/function should never see the data packet.For an OUT transaction I think the host controller might still send the DATA packet, but the device controllers that I know don't make it visible to the application in that case.
...
Are you guys interested in comments from other people who know more about the kernel and how it works with USB? Your messages have been far too long to go into in any detail, but I will address this one issue.
The USB protocol forbids a device from sending a STALL response to a SETUP packet. The only valid response is ACK. Thus, there is no way to prevent the host from sending its DATA packet for a control-OUT transfer.
A gadget driver can STALL in response to a control-OUT data packet, but only before it has seen the packet. Once the driver knows what the data packet contains, the gadget API doesn't provide any way to STALL the status stage. There has been a proposal to change the API to make this possible, but so far it hasn't gone forward.
Alan Stern
Re: [PATCH v3 4/6] drm: Add Generic USB Display driver
Hi Alan,
Quoted 8 lines · Alan Stern
Quoted 8 lines
The way I read
composite_setup()aftertry_fun_setup: it callsf->setup()when available, and that can return < 0 to stall.I expect that
composite_setup()and thusf->setup()run when the SETUP packet has arrived, thus before the data packet arrives, and ifcomposite_setup()stalls then the device/function should never see the data packet.
Quoted 8 lines
Quoted 3 lines
For an OUT transaction I think the host controller might still send the DATA packet, but the device controllers that I know don't make it visible to the application in that case.
...
Are you guys interested in comments from other people who know more about the kernel and how it works with USB?
I am, especially when it comes to the gadget code.
Quoted 4 lines
The USB protocol forbids a device from sending a STALL response to a SETUP packet. The only valid response is ACK. Thus, there is no way to prevent the host from sending its DATA packet for a control-OUT transfer.
Right; a STALL handshake only after a DATA packet, but a udc could silently drop the first DATA packet if instructed to STALL during SETUP processing. I don't know how common that is for the udc:s supported by gadget, but some MCU:s behave like that.
Quoted 2 lines
A gadget driver can STALL in response to a control-OUT data packet, but only before it has seen the packet.
How can it do that for OUT, and IN if possible there too?
Is it related to f->setup() returning < 0 ?
The spec also allows NAK, but the gadget code seems to not (need to?) explicitly support that. Can you comment on this as well?
Quoted 2 lines
Once the driver knows what the data packet contains, the gadget API doesn't provide any way to STALL the status stage.
Thanks. I think this particular gadget driver doesn't need to decide late.
Ideally the control transfers can even be avoided.
Thanks and kind regards
//Peter
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 4/6] drm: Add Generic USB Display driver
In reply to Alan SternDen 02.06.2020 04.32, skrev Alan Stern:
Quoted 12 lines · Peter Stuge
...
Quoted 8 lines
The way I read
composite_setup()aftertry_fun_setup: it callsf->setup()when available, and that can return < 0 to stall.I expect that
composite_setup()and thusf->setup()run when the SETUP packet has arrived, thus before the data packet arrives, and ifcomposite_setup()stalls then the device/function should never see the data packet.
Quoted 8 lines
Quoted 3 lines
For an OUT transaction I think the host controller might still send the DATA packet, but the device controllers that I know don't make it visible to the application in that case.
...
Are you guys interested in comments from other people who know more about the kernel and how it works with USB?
Absolutely, I want something thats works well in the kernel and doesn't look odd to kernel USB people.
Quoted 8 lines
Your messages have been
far too long to go into in any detail, but I will address this one issue.The USB protocol forbids a device from sending a STALL response to a SETUP packet. The only valid response is ACK. Thus, there is no way to prevent the host from sending its DATA packet for a control-OUT transfer.
Quoted 6 lines
A gadget driver can STALL in response to a control-OUT data packet, but only before it has seen the packet. Once the driver knows what the data packet contains, the gadget API doesn't provide any way to STALL the status stage. There has been a proposal to change the API to make this possible, but so far it hasn't gone forward.
This confirms what I have seen in the kernel and the reason I added a status request so I can know the result of the operation the device has performed.
I have a problem that I've encountered with this status request. In my first version the gadget would usb_ep_queue() the status value when the operation was done and as long as this happended within the host timeout (5s) everything worked fine.
Then I hit a 10s timeout in the gadget when performing a display modeset operation (wait on missing vblank). The result of this was that the host timed out and moved on. The gadget however didn't know that the host gave up, so it queued up the status value. The result of this was that all further requests from the host would time out.
Do you know a solution to this?
My work around is to just poll on the status request, which returns a value immediately, until there's a result. The udc driver I use is dwc2.
Noralf.
Quoted 2 lines
Alan Stern
Re: [PATCH v3 4/6] drm: Add Generic USB Display driver
In reply to Peter StugeQuoted 9 lines · Peter Stuge
Quoted 4 lines
The USB protocol forbids a device from sending a STALL response to a SETUP packet. The only valid response is ACK. Thus, there is no way to prevent the host from sending its DATA packet for a control-OUT transfer.
Right; a STALL handshake only after a DATA packet, but a udc could silently drop the first DATA packet if instructed to STALL during SETUP processing. I don't know how common that is for the udc:s supported by gadget, but some MCU:s behave like that.
It happens from time to time, such as when the host sends a SETUP packet that the gadget driver doesn't understand.
Quoted 4 lines
Quoted 2 lines
A gadget driver can STALL in response to a control-OUT data packet, but only before it has seen the packet.
How can it do that for OUT, and IN if possible there too?
In the way described just above: The gadget driver's SETUP handler tells the UDC to stall the data packet.
Quoted 1 line
Is it related to
f->setup()returning < 0 ?
Yes; the composite core interprets such a value as meaning to STALL endpoint 0.
Quoted 2 lines
The spec also allows NAK, but the gadget code seems to not (need to?) explicitly support that. Can you comment on this as well?
If the gadget driver doesn't submit a usb_request then the UDC will reply with NAK.
Quoted 6 lines
Quoted 2 lines
Once the driver knows what the data packet contains, the gadget API doesn't provide any way to STALL the status stage.
Thanks. I think this particular gadget driver doesn't need to decide late.
Ideally the control transfers can even be avoided.
Quoted 10 lines · Noralf Trønnes
Quoted 6 lines
A gadget driver can STALL in response to a control-OUT data packet, but only before it has seen the packet. Once the driver knows what the data packet contains, the gadget API doesn't provide any way to STALL the status stage. There has been a proposal to change the API to make this possible, but so far it hasn't gone forward.
This confirms what I have seen in the kernel and the reason I added a status request so I can know the result of the operation the device has performed.
Does this status request use ep0 or some other endpoint?
Quoted 5 lines
I have a problem that I've encountered with this status request. In my first version the gadget would
usb_ep_queue()the status value when the operation was done and as long as this happended within the host timeout (5s) everything worked fine.
Quoted 8 lines
Then I hit a 10s timeout in the gadget when performing a display modeset operation (wait on missing vblank). The result of this was that the host timed out and moved on. The gadget however didn't know that the host gave up, so it queued up the status value. The result of this was that all further requests from the host would time out.
Do you know a solution to this?
My work around is to just poll on the status request, which returns a value immediately, until there's a result. The udc driver I use is dwc2.
It's hard to give a precise answer without knowing the details of how your driver works.
There are two reasonable approaches you could use. One is to have a vendor-specific control request to get the result of the preceding operation. This works but it has high overhead -- which may not matter if it happens infrequently and isn't sensitive to latency.
The other approach is to send the status data over a bulk-IN endpoint. It would have to be formatted in such a way that the host could recognize it as a status packet and not some other sort of data packet. That way, if the host received a stale status value, it could ignore it and move on.
You also may want to give some thought to a "resynchronization" protocol, for use in situations where the host times out waiting for a response from the device while the device is waiting for something else (the host, a vblank, or whatever). This could be a special control request, or you could rely on the host doing a complete USB reset.
Alan Stern
Re: [PATCH v3 6/6] usb: gadget: function: Add Generic USB Display support
In reply to Noralf TrønnesHi,
I missed this completely until now.
Quoted 9 lines · Noralf Trønnes
This adds the gadget side support for the Generic USB Display. It presents a DRM display device as a USB Display configured through configfs.
The display is implemented as a vendor type USB interface with one bulk out endpoint. The protocol is implemented using control requests. lz4 compressed framebuffer data/pixels are sent over the bulk endpoint.
The DRM part of the gadget is placed in the DRM subsystem since it reaches into the DRM internals.
First and foremost, could this be done in userspace using the raw gadget or f_fs?
drivers/usb/gadget/function/f_gud_drm.c line 3
Quoted 9 lines
drivers/usb/gadget/function/f_gud_drm.c new file +3
-0@@ -0,0 +1,678 @@ +struct f_gud_drm { +struct usb_function func; +struct work_struct worker;
why do you need a worker?
drivers/usb/gadget/function/f_gud_drm.c line 30
Quoted 8 lines
drivers/usb/gadget/function/f_gud_drm.c new file +8
-0+size_t max_buffer_size; +void *ctrl_req_buf; + +u8 interface_id; +struct usb_request *ctrl_req; + +struct usb_ep *bulk_ep; +struct usb_request *bulk_req;
single request? Don't you want to amortize the latency of queue->complete by using a series of requests?
drivers/usb/gadget/function/f_gud_drm.c line 38
Quoted 7 lines
drivers/usb/gadget/function/f_gud_drm.c new file +7
-0+struct gud_drm_gadget *gdg; + +spinlock_t lock;/* Protects the following members: */ +bool ctrl_pending; +bool status_pending; +bool bulk_pending; +bool disable_pending;
could this be a single u32 with #define'd flags? That would be atomic, right?
drivers/usb/gadget/function/f_gud_drm.c line 39
Quoted 1 line
drivers/usb/gadget/function/f_gud_drm.c new file +1
-0+u8 errno;
a global per-function error? Why?
drivers/usb/gadget/function/f_gud_drm.c line 41
Quoted 2 lines
drivers/usb/gadget/function/f_gud_drm.c new file +2
-0+u16 request; +u16 value;
also why? Looks odd
drivers/usb/gadget/function/f_gud_drm.c line 44
Quoted 3 lines
drivers/usb/gadget/function/f_gud_drm.c new file +3
-0+}; + +static inline struct f_gud_drm *func_to_f_gud_drm (struct usb_function *f)
let the compiler inline for you
drivers/usb/gadget/function/f_gud_drm.c line 46
Quoted 2 lines
drivers/usb/gadget/function/f_gud_drm.c new file +2
-0+{ + return container_of(f, struct f_gud_drm, func);
could be a macro, but okay.
drivers/usb/gadget/function/f_gud_drm.c line 58
Quoted 1 line
drivers/usb/gadget/function/f_gud_drm.c new file +1
-0+static inline struct f_gud_drm_opts *fi_to_f_gud_drm_opts (const struct usb_function_instance *fi)
ditto
drivers/usb/gadget/function/f_gud_drm.c line 29
Quoted 2 lines
drivers/usb/gadget/function/f_gud_drm.c new file +2
-0+{ + return container_of(fi, struct f_gud_drm_opts, func_inst);
ditto
drivers/usb/gadget/function/f_gud_drm.c line 63
Quoted 3 lines
drivers/usb/gadget/function/f_gud_drm.c new file +3
-0+} + +static inline struct f_gud_drm_opts *ci_to_f_gud_drm_opts (struct config_item *item)
ditto
drivers/usb/gadget/function/f_gud_drm.c line 66
Quoted 3 lines
drivers/usb/gadget/function/f_gud_drm.c new file +3
-0+{ + return container_of(to_config_group(item), struct f_gud_drm_opts, + func_inst.group);
ditto
drivers/usb/gadget/function/f_gud_drm.c line 70
Quoted 4 lines
drivers/usb/gadget/function/f_gud_drm.c new file +4
-0+} + +#define F_MUD_DEFINE_BULK_ENDPOINT_DESCRIPTOR (name, addr, size) \ + static struct usb_endpoint_descriptor name = { \
const? Also, please check all the others
drivers/usb/gadget/function/f_gud_drm.c line 136
Quoted 7 lines
drivers/usb/gadget/function/f_gud_drm.c new file +7
-0+static void f_gud_drm_bulk_complete (struct usb_ep *ep,struct usb_request *req) +{ +struct f_gud_drm *fgd = req->context; +unsigned long flags; + +if (req->status || req->actual != req->length) +return ;
so, if we complete with an erroneous status or a short packet, you'll ignore it?
drivers/usb/gadget/function/f_gud_drm.c line 142
Quoted 5 lines
drivers/usb/gadget/function/f_gud_drm.c new file +5
-0+spin_lock_irqsave (&fgd->lock, flags); + fgd->bulk_pending = true; +spin_unlock_irqrestore (&fgd->lock, flags); + +queue_work (system_long_wq, &fgd->worker);
Do you need to offset this to a worker?
Quoted 28 lines
drivers/usb/gadget/function/f_gud_drm.c new file +28
-0+static int f_gud_drm_ctrl_req_set_buffer (struct f_gud_drm *fgd,void *buf,size_t len) +{ +int ret; + +if (len !=sizeof (struct gud_drm_req_set_buffer )) +return -EINVAL ; + + ret =gud_drm_gadget_set_buffer (fgd->gdg, buf); +if (ret <0 ) +return ret; + +if (ret > fgd->max_buffer_size) +return -EOVERFLOW ; + + fgd->bulk_req->length = ret; + +return usb_ep_queue (fgd->bulk_ep, fgd->bulk_req,GFP_KERNEL ); +} + +static void f_gud_drm_worker (struct work_struct *work) +{ + struct f_gud_drm *fgd = container_of(work, struct f_gud_drm, worker); +bool ctrl_pending, bulk_pending, disable_pending; +struct gud_drm_gadget *gdg = fgd->gdg; +unsigned long flags; +u16 request, value; +int ret; +
drivers/usb/gadget/function/f_gud_drm.c line 182
Quoted 10 lines
drivers/usb/gadget/function/f_gud_drm.c new file +10
-0+spin_lock_irqsave (&fgd->lock, flags); + request = fgd->request; + value = fgd->value; + ctrl_pending = fgd->ctrl_pending; + bulk_pending = fgd->bulk_pending; + disable_pending = fgd->disable_pending; +spin_unlock_irqrestore (&fgd->lock, flags); + +pr_debug ("%s: bulk_pending=%u ctrl_pending=%u disable_pending=%u\n" , + __func__, bulk_pending, ctrl_pending, disable_pending);
could we use dev_dbg() at least?
Signature · 1 line
balbi
Re: [PATCH v3 4/6] drm: Add Generic USB Display driver
In reply to Alan SternQuoted 5 lines · Alan Stern
Quoted 4 lines
Quoted 2 lines
A gadget driver can STALL in response to a control-OUT data packet, but only before it has seen the packet.
How can it do that for OUT, and IN if possible there too?
Quoted 7 lines
In the way described just above: The gadget driver's SETUP handler tells the UDC to stall the data packet.
Quoted 1 line
Is it related to
f->setup()returning < 0 ?Yes; the composite core interprets such a value as meaning to STALL endpoint 0.
Thanks a lot for confirming this.
Quoted 5 lines
Quoted 2 lines
The spec also allows NAK, but the gadget code seems to not (need to?) explicitly support that. Can you comment on this as well?
If the gadget driver doesn't submit a
usb_requestthen the UDC will reply with NAK.
And thanks for this as well.
Quoted 2 lines
Quoted 2 lines
a status request so I can know the result of the operation the device has performed.
..
Quoted 3 lines
There are two reasonable approaches you could use. One is to have a vendor-specific control request to get the result of the preceding operation.
..
Quoted 1 line
The other approach is to send the status data over a bulk-IN endpoint.
I've tried to explain a third approach, which I think fits well because the status is only a "Ready" flag - ie. a memory barrier or flow control, to make the host not send data OUT.
I'm proposing that the gadget should NAK on data OUT when it isn't Ready, and that the host driver shouldn't query status but simply send data when it has.
Per Alans description the NAK happens automatically if the gadget driver has no usb_request pending while it is processing previously received data.
On the host that NAK makes the host controller retry automatically until transfer success, timeout or fatal error.
Quoted 2 lines
It would have to be formatted in such a way that the host could recognize it as a status packet and not some other sort of data packet.
For host notification of status changes other than Ready I really like such an IN endpoint, but preferably an interrupt endpoint.
To avoid the formatting problem each data packet could be one full status message. That way the host would always receive a known data structure. Interrupt packets can be max 64 byte. Noralf, do you think that's enough for everyone in the first version?
//Peter
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 6/6] usb: gadget: function: Add Generic USB Display support
In reply to Felipe BalbiHi,
Den 02.06.2020 19.05, skrev Felipe Balbi:
Quoted 12 lines
Hi,
I missed this completely until now.
Quoted 7 lines · Noralf Trønnes
This adds the gadget side support for the Generic USB Display. It presents a DRM display device as a USB Display configured through configfs.
The display is implemented as a vendor type USB interface with one bulk out endpoint. The protocol is implemented using control requests. lz4 compressed framebuffer data/pixels are sent over the bulk endpoint.
Quoted 6 lines
Quoted 2 lines
The DRM part of the gadget is placed in the DRM subsystem since it reaches into the DRM internals.
First and foremost, could this be done in userspace using the raw gadget or
f_fs?
An uncompressed 1920x1080-RGB565 frame is ~4MB. All frames can be compressed (lz4) even if just a little, so this is decompressed into the framebuffer of the attached DRM device. AFAIU I would need to be able to mmap the received bulk buffer if I were to do this from userspace without killing performance. So it doesn't look like I can use raw gadget or f_fs.
Quoted 12 lines
drivers/usb/gadget/function/f_gud_drm.c line 3
Quoted 9 lines
drivers/usb/gadget/function/f_gud_drm.c new file +3
-0@@ -0,0 +1,678 @@ +struct f_gud_drm { +struct usb_function func; +struct work_struct worker;why do you need a worker?
The gadget runs in interrupt context and I need to call into the DRM subsystem which can sleep.
Quoted 12 lines
drivers/usb/gadget/function/f_gud_drm.c line 30
Quoted 8 lines
drivers/usb/gadget/function/f_gud_drm.c new file +8
-0+size_t max_buffer_size; +void *ctrl_req_buf; + +u8 interface_id; +struct usb_request *ctrl_req; + +struct usb_ep *bulk_ep; +struct usb_request *bulk_req;single request? Don't you want to amortize the latency of
queue->completeby using a series of requests?
I use only one request per update or partial update.
I kmalloc the biggest buffer I can get (default 4MB) and tell the host about this size. If a frame doesn't fit, the host splits it up into partial updates. I already support partial updates so this is built in. Userspace can tell the graphics driver which portion of the framebuffer it has touched to avoid sending the full frame each time. Having one continous buffer simplifies decompression.
There's a control request preceding the bulk request which tells the area the update is for and whether it is compressed or not. I did some testing to see if I should avoid the control request overhead for split updates, but it turns out that the bottleneck is the decompression. The control request is just 400-500us, while the total time from control request to buffer is decompressed is 50-100ms (depending on how well the frame compresses).
Quoted 11 lines
drivers/usb/gadget/function/f_gud_drm.c line 38
Quoted 7 lines
drivers/usb/gadget/function/f_gud_drm.c new file +7
-0+struct gud_drm_gadget *gdg; + +spinlock_t lock;/* Protects the following members: */ +bool ctrl_pending; +bool status_pending; +bool bulk_pending; +bool disable_pending;could this be a single u32 with #define'd flags? That would be atomic, right?
I have never grasped all the concurrency issues, but wouldn't I need memory barriers as well?
Quoted 4 lines
drivers/usb/gadget/function/f_gud_drm.c line 39
Quoted 1 line
drivers/usb/gadget/function/f_gud_drm.c new file +1
-0+u8 errno;a global per-function error? Why?
This is the result of the previously request operation. The host will request this value to see how it went. I might switch to using a bulk endpoint for status following a discussion with Alan Stern in the host driver thread in this patch series. If so I might not need this.
Quoted 5 lines
drivers/usb/gadget/function/f_gud_drm.c line 41
Quoted 2 lines
drivers/usb/gadget/function/f_gud_drm.c new file +2
-0+u16 request; +u16 value;also why? Looks odd
These values contains the operation (in addition to the payload) that the worker shall perform following the control-OUT requests.
control-IN requests can run in interrupt context so in that case the payload is queued up immediately.
<snip>
Quoted 11 lines
drivers/usb/gadget/function/f_gud_drm.c line 136
Quoted 7 lines
drivers/usb/gadget/function/f_gud_drm.c new file +7
-0+static void f_gud_drm_bulk_complete (struct usb_ep *ep,struct usb_request *req) +{ +struct f_gud_drm *fgd = req->context; +unsigned long flags; + +if (req->status || req->actual != req->length) +return ;so, if we complete with an erroneous status or a short packet, you'll ignore it?
Hmm yeah. When I wrote this I thought that the bottleneck was the USB transfers, so I didn't want the host to slow down performance by requesting this status. Now I know it's the decompression that takes time, so I could actually do a status check and retry the frame if the device detects an error.
Quoted 8 lines
drivers/usb/gadget/function/f_gud_drm.c line 142
Quoted 5 lines
drivers/usb/gadget/function/f_gud_drm.c new file +5
-0+spin_lock_irqsave (&fgd->lock, flags); + fgd->bulk_pending = true; +spin_unlock_irqrestore (&fgd->lock, flags); + +queue_work (system_long_wq, &fgd->worker);Do you need to offset this to a worker?
Yes, long running (one operation can be >100ms) and can sleep.
Quoted 32 lines
Quoted 32 lines
drivers/usb/gadget/function/f_gud_drm.c new file +32
-0+static int f_gud_drm_ctrl_req_set_buffer (struct f_gud_drm *fgd,void *buf,size_t len) +{ +int ret; + +if (len !=sizeof (struct gud_drm_req_set_buffer )) +return -EINVAL ; + + ret =gud_drm_gadget_set_buffer (fgd->gdg, buf); +if (ret <0 ) +return ret; + +if (ret > fgd->max_buffer_size) +return -EOVERFLOW ; + + fgd->bulk_req->length = ret; + +return usb_ep_queue (fgd->bulk_ep, fgd->bulk_req,GFP_KERNEL ); +} + +static void f_gud_drm_worker (struct work_struct *work) +{ + struct f_gud_drm *fgd = container_of(work, struct f_gud_drm, worker); +bool ctrl_pending, bulk_pending, disable_pending; +struct gud_drm_gadget *gdg = fgd->gdg; +unsigned long flags; +u16 request, value; +int ret; + +spin_lock_irqsave (&fgd->lock, flags); + request = fgd->request; + value = fgd->value; + ctrl_pending = fgd->ctrl_pending;
Quoted 9 lines
drivers/usb/gadget/function/f_gud_drm.c line 182
Quoted 6 lines
drivers/usb/gadget/function/f_gud_drm.c new file +6
-0+ bulk_pending = fgd->bulk_pending; + disable_pending = fgd->disable_pending; +spin_unlock_irqrestore (&fgd->lock, flags); + +pr_debug ("%s: bulk_pending=%u ctrl_pending=%u disable_pending=%u\n" , + __func__, bulk_pending, ctrl_pending, disable_pending);could we use
dev_dbg()at least?
Sure.
Noralf.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 6/6] usb: gadget: function: Add Generic USB Display support
Hi,
Quoted 16 lines · Noralf Trønnes
Quoted 9 lines
I missed this completely until now.
Quoted 7 lines · Noralf Trønnes
This adds the gadget side support for the Generic USB Display. It presents a DRM display device as a USB Display configured through configfs.
The display is implemented as a vendor type USB interface with one bulk out endpoint. The protocol is implemented using control requests. lz4 compressed framebuffer data/pixels are sent over the bulk endpoint.
Quoted 6 lines
Quoted 2 lines
The DRM part of the gadget is placed in the DRM subsystem since it reaches into the DRM internals.
First and foremost, could this be done in userspace using the raw gadget or
f_fs?
Quoted 6 lines
An uncompressed 1920x1080-RGB565 frame is ~4MB. All frames can be compressed (lz4) even if just a little, so this is decompressed into the framebuffer of the attached DRM device. AFAIU I would need to be able to mmap the received bulk buffer if I were to do this from userspace without killing performance. So it doesn't look like I can use raw gadget or
f_fs.
oh, yeah we couldn't map that much. I was thinking that maybe we could transfer several small buffers instead of a single large one, but perhaps that would complicate decompression?
Quoted 13 lines
Quoted 12 lines
drivers/usb/gadget/function/f_gud_drm.c line 3
Quoted 9 lines
drivers/usb/gadget/function/f_gud_drm.c new file +3
-0@@ -0,0 +1,678 @@ +struct f_gud_drm { +struct usb_function func; +struct work_struct worker;why do you need a worker?
Quoted 2 lines
The gadget runs in interrupt context and I need to call into the DRM subsystem which can sleep.
At some point someone wanted to provide a patch to run endpoint giveback routine in process context, much like usb host stack does if requested. That's currently not implemented, but should be doable by modifying usb_gadget_giveback_request().
Quoted 13 lines
Quoted 12 lines
drivers/usb/gadget/function/f_gud_drm.c line 30
Quoted 8 lines
drivers/usb/gadget/function/f_gud_drm.c new file +8
-0+size_t max_buffer_size; +void *ctrl_req_buf; + +u8 interface_id; +struct usb_request *ctrl_req; + +struct usb_ep *bulk_ep; +struct usb_request *bulk_req;single request? Don't you want to amortize the latency of
queue->completeby using a series of requests?
Quoted 7 lines
I use only one request per update or partial update.
I kmalloc the biggest buffer I can get (default 4MB) and tell the host about this size. If a frame doesn't fit, the host splits it up into partial updates. I already support partial updates so this is built in. Userspace can tell the graphics driver which portion of the framebuffer it has touched to avoid sending the full frame each time. Having one continous buffer simplifies decompression.
got it
Quoted 7 lines
There's a control request preceding the bulk request which tells the area the update is for and whether it is compressed or not. I did some testing to see if I should avoid the control request overhead for split updates, but it turns out that the bottleneck is the decompression. The control request is just 400-500us, while the total time from control request to buffer is decompressed is 50-100ms (depending on how well the frame compresses).
yeah, that makes sense.
Quoted 12 lines
Quoted 11 lines
drivers/usb/gadget/function/f_gud_drm.c line 38
Quoted 7 lines
drivers/usb/gadget/function/f_gud_drm.c new file +7
-0+struct gud_drm_gadget *gdg; + +spinlock_t lock;/* Protects the following members: */ +bool ctrl_pending; +bool status_pending; +bool bulk_pending; +bool disable_pending;could this be a single u32 with #define'd flags? That would be atomic, right?
Quoted 2 lines
I have never grasped all the concurrency issues, but wouldn't I need memory barriers as well?
As far as I understand, {test_and_,}{set,clear,change}_bit() handle all the required steps to guarantee proper atomic behavior. I haven't looked at the implementation myself, though.
Quoted 9 lines
Quoted 4 lines
drivers/usb/gadget/function/f_gud_drm.c line 39
Quoted 1 line
drivers/usb/gadget/function/f_gud_drm.c new file +1
-0+u8 errno;a global per-function error? Why?
This is the result of the previously request operation. The host will request this value to see how it went. I might switch to using a bulk endpoint for status following a discussion with Alan Stern in the host driver thread in this patch series. If so I might not need this.
got it.
Quoted 11 lines
Quoted 5 lines
drivers/usb/gadget/function/f_gud_drm.c line 41
Quoted 2 lines
drivers/usb/gadget/function/f_gud_drm.c new file +2
-0+u16 request; +u16 value;also why? Looks odd
These values contains the operation (in addition to the payload) that the worker shall perform following the control-OUT requests.
control-IN requests can run in interrupt context so in that case the payload is queued up immediately.
cool
Quoted 12 lines
Quoted 11 lines
drivers/usb/gadget/function/f_gud_drm.c line 136
Quoted 7 lines
drivers/usb/gadget/function/f_gud_drm.c new file +7
-0+static void f_gud_drm_bulk_complete (struct usb_ep *ep,struct usb_request *req) +{ +struct f_gud_drm *fgd = req->context; +unsigned long flags; + +if (req->status || req->actual != req->length) +return ;so, if we complete with an erroneous status or a short packet, you'll ignore it?
Quoted 5 lines
Hmm yeah. When I wrote this I thought that the bottleneck was the USB transfers, so I didn't want the host to slow down performance by requesting this status. Now I know it's the decompression that takes time, so I could actually do a status check and retry the frame if the device detects an error.
sounds good :-)
Signature · 1 line
balbi
Re: [PATCH v3 4/6] drm: Add Generic USB Display driver
In reply to Peter StugeDen 02.06.2020 02.12, skrev Peter Stuge:
Quoted 18 lines
Hi Noralf,
Thanks a lot for going into more detail.
Quoted 6 lines · Noralf Trønnes
Quoted 5 lines
Several Linux/DRM internals have "leaked" into the USB protocol - this should be avoided if you want device implementations other than your gadget, because those internals can change within Linux in the future, while the protocol must not.
Quoted 6 lines
That's intentional, I see no point in recreating uapi values that won't change:
Linux errno: /include/uapi/asm-generic/errno{-base,}.h Pixel formats:
include/uapi/drm/drm_fourcc.hConnector types and status:include/uapi/drm/drm_mode.h
Quoted 8 lines
I understand, and it's good that these are uapi values, but I will still disagree with using errno and DRM connector types in the USB protocol, which is a "namespace" of its own.
That is an important point here; GUD is three things: a Linux DRM driver, a Linux gadget driver and a USB protocol. USB protocols (good ones) are OS-agnostic.
I need to be more clear here about the word 'Generic' that I've used.
This is not a OS-agnostic protocol. It's written for Linux. I have had the BSD's in mind, hence the MIT license, FreeBSD for instance has a DRM subsystem. Other OS'es might not support all DRM properties, but should be able to use it as a basic display. They will ofc need to translate the Linux DRM specifics into their own environment. But first and foremost this is for Linux.
The host driver is written against the capabilities of the Linux gadget framework and the DRM subsystem. This will add some peculiarities that a microcontroller implementation won't face. The focal point of the project is providing as good performance as possible for Full HD desktop use.
The word 'Generic' means that it's (should be) possible to make a USB display for use on Linux without having to write a graphics driver. This includes all kinds of tiny/small displays that currently are SPI or I2C interfaced. These will probably use a microcontroller instead of a Linux SoC to keep cost low.
Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
If the device transfer buffer can't fit an uncompressed framebuffer update, the update is split up into parts that do fit.
Quoted 8 lines
Quoted 3 lines
Does "device transfer buffer" refer to something like display RAM on the device side? If so, its size is a device implementation detail which shouldn't be exposed over USB.
The reason for exposing this is that the Linux gadget driver needs to decompress the transfer into a buffer and the host needs to know how big this is (the host can choose to lower this if it can't allocate a continuous buffer of this size).
Quoted 8 lines
I understand; so it's only required for some compression types - then it should at least be completely optional, but in any case I find exposing/having to expose this to be awful USB protocol design and I hope we can find a better way.
Maybe it's premature anyway? How would you feel about skipping compression to begin with?
Performance is not good without compression so I need to keep that.
Quoted 10 lines
Quoted 7 lines
lz4 (in the kernel) is block compression and can't be used for decompressing just a stream of bytes. There is a lz4 frame protocol which looks like it could be useful, but it's not available in the kernel. I hardly know anything about compression so I'm in no position to add that to the kernel. Maybe someone will add it at a later time if it is useful.
Why did you choose to use lz4?
The kernel supports it and in actually performs quite well. Decompression is much faster than compression which fits nicely with not so powerful USB devices. Low resolution displays might not need compression at all.
Quoted 3 lines
Whether compression comes now or later, maybe there is a more suitable algorithm?
Could be, it's possible to support other compression methods. I'll leave that to the professionals that need it for their display.
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines
The R1 idea is great!
My plan was to remove R1 support from this version of the patchset, but I forgot. The reason is that it's cumbersome to test when the gadget driver doesn't support it.
Why not support R1 also in the gadget?
The DRM subsystem doesn't have support for it so the gadget wouldn't know when to use it. Monochrome DRM drivers advertise a XRGB8888 format and converts this into monochrome. The reason for using this format is because all userspace supports it. AFAIK no DRM userspace support monochrome.
Quoted 8 lines
Quoted 3 lines
You mention further down that you have use cases for this, do you have a timeplan for when you will make use of R1?
No strict plan, but if it helps I could make a demo device and -firmware without much effort. You mentioned that you would like to have a microcontroller device for testing?
I have done a microcontroller implementation, so I have tried it. It's quite a different environment to work in than Linux for sure :-) It might have been a more pleasant experience if I'd spent money on a professional compiler/IDE I guess.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines
- Use donated Openmoko USB pid
If Linux will be the reference for this protocol then perhaps a PID under the Linux Foundation VID (1d6b) makes more sense?
Quoted 9 lines
Quoted 1 line
Do they hand out pid's?
I don't know. :) The root hub drivers each have one.
Quoted 1 line
To me it's no big deal, it can be added later if someones cares about it.
Okay, hopefully we can do without a PID anyway.
That can't happen AFAIK. This would require the driver to probe all USB devices with a vendor interface. Who knows what kind a havoc this might cause on the device in question.
Quoted 29 lines
Quoted 8 lines
Quoted 2 lines
But: A PID applies on device level, not to interfaces.
Indeed. This is a USB interface driver though, so it only looks at vendor class interfaces. Then it checks if there's a bulk out endpoint, if not it returns
-ENXIOand the device subsytem moves on to another interface driver if any. Next it tries to fetch the display descriptor and if not succesful it returns-ENODEVto give another driver a chance.Thanks for clarifying this flow. It's nice not to require particular endpoint addresses - that makes the protocol/driver much more generic.
Quoted 2 lines
I have tried my best to let the driver tolerate other vendor class interfaces on the device.
Ack, this is clear now.
Quoted 3 lines
I don't understand why PID should not be necessary, I'm using a vendor class interface and the driver can't probe all of those, so it has to look at specific vid:pid's.
Why can't the driver probe all vendor class interfaces?
To probe fewer interfaces, a criteria other than PID can still be defined, and doing so would enable immediate plug-and-play for non-gadget and especially composite devices, without requiring the addition of PIDs in the host driver.
Quoted 8 lines
I find this possibility especially attractive for composite devices, which may already have some VID:PID and a non-GUD primary function/interface that is handled by another driver, such that a GUD PID effectively can't be adopted for that device.
One example of such a criteria would be to require that the iInterface string descriptor contains the (sub)string "Generic USB Display".
I can consider a driver that looks at all vendor interfaces if you can find a driver in the kernel that does this.
Quoted 59 lines
Quoted 13 lines
Quoted 13 lines
Quoted 3 lines
drivers/gpu/drm/gud/gud_drm_drv.c new file +3
-0+static int gud_get_vendor_descriptor (struct usb_interface *interface, +struct gud_drm_display_descriptor *desc) +{..
drivers/gpu/drm/gud/gud_drm_drv.c line 83
Quoted 2 lines
drivers/gpu/drm/gud/gud_drm_drv.c new file +2
-0+ ret =gud_drm_usb_control_msg (usb, ifnum, true,USB_REQ_GET_DESCRIPTOR , +GUD_DRM_USB_DT_DISPLAY <<8 , buf,sizeof (*desc), false);
GUD_DRM_USB_DT_DISPLAYis defined as (USB_TYPE_VENDOR|0x4), butUSB_TYPE_VENDORonly applies to bmRequestType[6:5] in control transfers, nowhere else. I know of no standardized way to introduce vendor-specific descriptors. Squatting is possible, but I think it would be nice to do better here. It is easy enough.Quoted 7 lines
Quoted 5 lines
It could be argued that the vendor specific interface gives flexibility here, but actually it just means that the semantics of the standardized and well-defined
USB_REQ_GET_DESCRIPTORhave been duplicated by this protocol, that is not very common - but if you want to go ahead then at least dropUSB_TYPE_VENDORfrom theGUD_DRM_USB_DT_DISPLAYdefinition.I liked that it is well defined and understood, so I didn't have to be clever.
I tried to explain that it is only well defined for the standardized
GET_DESCRIPTORrequest with device recipient. The concept "descriptor" isn't used anywhere else by other USB protocols that I know.There are various class-specific descriptors, but they are all standardized in USB-IF device class specs, and all of them are only ever retrieved by the standardized
GET_DESCRIPTORrequest.Because of that it's actually rather confusing to me to refer to the display data structure as a descriptor and even use the standardized descriptor header and naming convention when it is actually /not/ a descriptor, since it isn't standardized and isn't retrievable with the standardized
GET_DESCRIPTORrequest. Does that make sense?Quoted 3 lines
I like it and think I'll keep it, so I'll change the macro:
#define
GUD_DRM_USB_DT_DISPLAY0x44Okay. The number is arbitrary, since a control request directed to a vendor specific interface is vendor specific "by inheritance", thus also arbitrary.
Quoted 9 lines
Quoted 5 lines
Maybe it's good to think about the data exchange some more - anything not transfered by standardized
USB_REQ_GET_DESCRIPTOR(bmRequestType 10000000B; Device-to-host data, Standard type, Device recipient) isn't actually a descriptor, it's vendor-specific, free-format data. Does that enable any simplifications?Actually it is:
u8 requesttype = USB_TYPE_VENDOR | USB_RECIP_INTERFACE;Right; it's a Vendor-Specific type, Interface recipient request, thus not the standardized
USB_REQ_GET_DESCRIPTOR, and thus the data is not actually a descriptor, hence why calling it one is confusing to me.
Quoted 8 lines
Quoted 3 lines
see
gud_drm_usb_control_msg(). I could addGUD_DRM_USB_REQ_GET_DESCRIPTORinstead of usingUSB_REQ_GET_DESCRIPTORif that makes it any clearer.That would be an improvement, but I would really wish for different terminology all together.
Ok, if this is really confusing I need to fix it and I couldn't find a driver to support my case in the kernel either.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+static int
gud_usb_get_status(struct usb_device *usb, u8 ifnum)
I'm skipping the status poll discussion since I've discovered a bug in my previous code that broke on timeouts. I will to try and fix that first and see how it turns out.
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
drivers/gpu/drm/gud/gud_drm_drv.c line 295
Quoted 1 line
drivers/gpu/drm/gud/gud_drm_drv.c new file +1
-0+ shmem->map_cached = true;Can you explain what this does exactly?
Quoted 10 lines
Quoted 5 lines
Not excatly, but I can try rather vaguely :-) The memory subsystem is a black box to me. It has to do with the memory page attribute that controls how memory access is handled by the CPU cache. The default for shmem is WriteCombined which makes for slow read access on ARM, but on x86 there doesn't seem to be any penalty judging by my brief testing.
Hmm. ARM often (always?) can't do byte-aligned access, only 32-bit access. Do you know if and how the buffer is aligned? Maybe this can make a difference?
The start of the buffer is word aligned to match the arch, the memory subsystem takes care of that, otherwise we would have all kinds of trouble.
Quoted 15 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/gud/gud_drm_drv.c new file +3
-0+static int gud_drm_probe (struct usb_interface *interface, +const struct usb_device_id *id) +{..
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/gud/gud_drm_drv.c line 424
Quoted 4 lines
drivers/gpu/drm/gud/gud_drm_drv.c new file +4
-0+/* Check if the device can support us */ + *version =1 ; + ret =gud_drm_usb_control_msg (usb, ifnum, false,GUD_DRM_USB_REQ_SET_VERSION , +0 , version,sizeof (*version), true);A more USB:y way would btw. be to report the highest supported protocol version to the host in some data structure.
This too could be the iInterface string descriptor.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Could't this work without
_get_status()? What doesusb_control_msg()return for a STALL handshake in the data stage?It returns
-EPIPE, but as mentioned above, I can't stall a control write request with payload.Please check this? It looks to me like it would be possible.
Alan confirmed what I read in the kernel source in his reply.
Quoted 10 lines
Quoted 5 lines
Quoted 1 line
Or at least in
Documentation/?Ideally I would have written a spec and made the implementation against it. However since I suck at writing, I even struggle with getting the compiler to understand me, so it won't happen. It would have taken me forever.
I have a template for USB protocols that I could use, perhaps we can make that spec a reality. I think it would be quite valuable, to help folks outside Linux who may also want to create a generic usb display.
I'm sorry but that's outside of the scope of the project and the effort I can put into it.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
drivers/gpu/drm/gud/gud_drm_pipe.c new file +4
-0+static size_t gud_drm_xrgb8888_to_r124 (u8 *dst,const struct drm_format_info *format, +void *src,struct drm_framebuffer *fb, +struct drm_rect *rect) +{..
Quoted 9 lines
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/gud/gud_drm_pipe.c line 56
Quoted 3 lines
drivers/gpu/drm/gud/gud_drm_pipe.c new file +3
-0+ buf =kmalloc (width * height,GFP_KERNEL ); +if (!buf) +return len;/* To keep logic simple, just transmit garbage */ Ouch! Shouldn't this bubble up somehow? If there is memory pressure then I really think something above should fail.
No comment on this?
I wanted to see if you were going to use R1 in the near future, otherwise I will remove this in the next version. I guess I'll fix this if it stays.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+static int gud_drm_fb_flush(struct
gud_drm_device*gdrm, structdrm_framebuffer*fb,
I need to delay commenting on the flow control issues for now. I'll pick it up later after some more study.
Quoted 10 lines
Quoted 9 lines
Quoted 6 lines
Why does the host software need to know anything about the connector inside the device, anyway? With a microcontroller that could be anything, especially with actual R1 displays.
Would it make sense to introduce
DRM_MODE_CONNECTOR_USBon the host, and keep this implementation detail in the device?For display adapters it makes sense especially when it has more than one connector like the Raspberry Pi which has an hdmi and a sdtv connector.
Quoted 7 lines
Right, a GUD device could have multiple connectors, I guess with one USB interface per connector, but again, what does the host really need to know about the connector beyond the supported pixel format(s)?
Thanks for mentioning SDTV - I wasn't sure about the rationale for those TV parts in the patch. Can you elaborate on that?
Those are properties exposed by the DRM subsystem for use on TV connectors. I actually don't know much details, I've just exposed them and tested that I can set margins.
Quoted 3 lines
If the idea is in fact to create "Linux DRM over USB" then by all means go for it, but in that case please don't call it generic.
I disagree, I believe this is generic, within the Linux world.
Quoted 6 lines
Quoted 5 lines
Quoted 1 line
I hope this helps.
Indeed it I does, it helps me revisit the decisions I've made and look at them in a new light. I have looked at the code for so long that I hardly see it anymore.
Quoted 7 lines
I know the feeling and I'm glad to help, but only if the goal is indeed to create a generic USB:y protocol, mostly if not completely free of Linux details.
If you're actually after something more closely tied to Linux/DRM then that's also a fun idea, but much less relevant for me.
I'm sorry, but this is Linux first and foremost.
Noralf.
Quoted 6 lines
Thanks and kind regards
//Peter
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 4/6] drm: Add Generic USB Display driver
In reply to Peter StugeDen 02.06.2020 20.38, skrev Peter Stuge:
Quoted 52 lines
Quoted 5 lines · Alan Stern
Quoted 4 lines
Quoted 2 lines
A gadget driver can STALL in response to a control-OUT data packet, but only before it has seen the packet.
How can it do that for OUT, and IN if possible there too?
Quoted 7 lines
In the way described just above: The gadget driver's SETUP handler tells the UDC to stall the data packet.
Quoted 1 line
Is it related to
f->setup()returning < 0 ?Yes; the composite core interprets such a value as meaning to STALL endpoint 0.
Thanks a lot for confirming this.
Quoted 5 lines
Quoted 2 lines
The spec also allows NAK, but the gadget code seems to not (need to?) explicitly support that. Can you comment on this as well?
If the gadget driver doesn't submit a
usb_requestthen the UDC will reply with NAK.And thanks for this as well.
Quoted 2 lines
Quoted 2 lines
a status request so I can know the result of the operation the device has performed.
..
Quoted 3 lines
There are two reasonable approaches you could use. One is to have a vendor-specific control request to get the result of the preceding operation.
..
Quoted 1 line
The other approach is to send the status data over a bulk-IN endpoint.
I've tried to explain a third approach, which I think fits well because the status is only a "Ready" flag - ie. a memory barrier or flow control, to make the host not send data OUT.
I'm proposing that the gadget should NAK on data OUT when it isn't Ready, and that the host driver shouldn't query status but simply send data when it has.
Per Alans description the NAK happens automatically if the gadget driver has no
usb_requestpending while it is processing previously received data.On the host that NAK makes the host controller retry automatically until transfer success, timeout or fatal error.
Quoted 2 lines
It would have to be formatted in such a way that the host could recognize it as a status packet and not some other sort of data packet.
Quoted 8 lines
For host notification of status changes other than Ready I really like such an IN endpoint, but preferably an interrupt endpoint.
To avoid the formatting problem each data packet could be one full status message. That way the host would always receive a known data structure. Interrupt packets can be max 64 byte. Noralf, do you think that's enough for everyone in the first version?
I'm going through some treatment that turned out to be worse than expected, so sadly I have to put this project on hold until my body recovers.
Noralf.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Hello,
On 29 May 2020 Noralf Trønnes wrote:
...
Quoted 8 lines
This series adds a USB host driver and a device/gadget driver to achieve that.
The reason for calling it 'Generic' is so anyone can make a USB display/adapter against this driver, all that's needed is to add a USB vid:pid. I have done a microcontroller implementation hack just to see how that would work out[1] (which unconvered a couple of bugs in the host driver).
...
This is actually very cool; finally a good way to drive the cheapo SPI/I2C displays from computers whose only means of expansion is USB with a little help from a microcontroller. I've actually had some success doing just that [1].
[1] https://assets.octodon.social/media_attachments/files/009/983/960/original/64ad8ea46c1b06c5.jpg
I suppose you can add:
I've had to jump through some hoops though.
My OLED display is a 128x64 SSD1306 [1] driven from the SPI bus. The frame buffer SRAM is normally scanned out in stripes of 8 vertical pixels called "pages". When the display is turned on its side, with "vertical addressing mode" and "segment remapping" enabled and bytes being sent LSB first, it appears linear -- it's easy to repaint the whole display from what is now the top left corner to the bottom right. This is very convenient for painting pixels as they come, without bufferring them or doing any conversions (assuming that memory and cpu cycles are at premium on MCUs).
[1] https://cdn-shop.adafruit.com/datasheets/SSD1306.pdf
There doesn't seem a comfortable way to do partial redraws though. Would you find it objectionable if the device could indicate that needs full frames instead of just the damaged areas? Perhaps then the driver wouldn't even need to bother issuing GUD_DRM_USB_REQ_SET_BUFFER to displays dumb enough to be incapable of partial redraws and decompression.
My work-in-progress code that works on STM32F103 (e.g. "Blue Pill" boards), or GD32VF103 (RISC-V "Polos Alef") is at [2]. The partial redraws that don't start from column zero or are not "page aligned" don't work correctly for the time being; X11 doesn't seem to care.
Thank you!
Lubo
Den 09.07.2020 18.32, skrev Lubomir Rintel:
Quoted 12 lines
Hello,
On 29 May 2020 Noralf Trønnes wrote:
...Quoted 8 lines
This series adds a USB host driver and a device/gadget driver to achieve that.
The reason for calling it 'Generic' is so anyone can make a USB display/adapter against this driver, all that's needed is to add a USB vid:pid. I have done a microcontroller implementation hack just to see how that would work out[1] (which unconvered a couple of bugs in the host driver).
Quoted 6 lines
...
This is actually very cool; finally a good way to drive the cheapo SPI/I2C displays from computers whose only means of expansion is USB with a little help from a microcontroller. I've actually had some success doing just that [1].
Nice to see a monochrome implementation, I actually planned to remove the R1 format from v3 since the gadget driver doesn't implement it. Having unused (and poorly tested) code isn't that great, but I forgot. It turns out it was a good thing that I forgot that :-)
Quoted 19 lines
[1] https://assets.octodon.social/media_attachments/files/009/983/960/original/64ad8ea46c1b06c5.jpg
I suppose you can add:
Tested-by Lubomir Rintel <[email protected]>I've had to jump through some hoops though.
My OLED display is a 128x64 SSD1306 [1] driven from the SPI bus. The frame buffer SRAM is normally scanned out in stripes of 8 vertical pixels called "pages". When the display is turned on its side, with "vertical addressing mode" and "segment remapping" enabled and bytes being sent LSB first, it appears linear -- it's easy to repaint the whole display from what is now the top left corner to the bottom right. This is very convenient for painting pixels as they come, without bufferring them or doing any conversions (assuming that memory and cpu cycles are at premium on MCUs).
Quoted 8 lines
[1] https://cdn-shop.adafruit.com/datasheets/SSD1306.pdf
There doesn't seem a comfortable way to do partial redraws though. Would you find it objectionable if the device could indicate that needs full frames instead of just the damaged areas? Perhaps then the driver wouldn't even need to bother issuing
GUD_DRM_USB_REQ_SET_BUFFERto displays dumb enough to be incapable of partial redraws and decompression.
Yeah I figured always having full updates might benefit/simplify monochrome devices, but I'd wait for an actual device needing it before adding it. Now that you need it, I'll add a flag for it in the next version.
I would like to keep the SET_BUFFER request since it will serve as a syncing point between the host and the device. I'm no USB expert but I assume that a bulk transfer can fail halfway through and result in the next update starting where the previous one failed and thus writing beyond the end of the display buffer.
Noralf.
Quoted 10 lines
My work-in-progress code that works on STM32F103 (e.g. "Blue Pill" boards), or GD32VF103 (RISC-V "Polos Alef") is at [2]. The partial redraws that don't start from column zero or are not "page aligned" don't work correctly for the time being; X11 doesn't seem to care.
Thank you!
Lubo
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 4/6] drm: Add Generic USB Display driver
In reply to Noralf TrønnesDen 02.06.2020 13.46, skrev Noralf Trønnes:
Quoted 51 lines
Den 02.06.2020 04.32, skrev Alan Stern:
Quoted 12 lines · Peter Stuge
...
Quoted 8 lines
The way I read
composite_setup()aftertry_fun_setup: it callsf->setup()when available, and that can return < 0 to stall.I expect that
composite_setup()and thusf->setup()run when the SETUP packet has arrived, thus before the data packet arrives, and ifcomposite_setup()stalls then the device/function should never see the data packet.Quoted 8 lines
Quoted 3 lines
For an OUT transaction I think the host controller might still send the DATA packet, but the device controllers that I know don't make it visible to the application in that case.
...
Are you guys interested in comments from other people who know more about the kernel and how it works with USB?
Absolutely, I want something thats works well in the kernel and doesn't look odd to kernel USB people.
Quoted 8 lines
Your messages have been
far too long to go into in any detail, but I will address this one issue.The USB protocol forbids a device from sending a STALL response to a SETUP packet. The only valid response is ACK. Thus, there is no way to prevent the host from sending its DATA packet for a control-OUT transfer.
Quoted 6 lines
A gadget driver can STALL in response to a control-OUT data packet, but only before it has seen the packet. Once the driver knows what the data packet contains, the gadget API doesn't provide any way to STALL the status stage. There has been a proposal to change the API to make this possible, but so far it hasn't gone forward.
This confirms what I have seen in the kernel and the reason I added a status request so I can know the result of the operation the device has performed.
I have a problem that I've encountered with this status request. In my first version the gadget would
usb_ep_queue()the status value when the operation was done and as long as this happended within the host timeout (5s) everything worked fine.
Quoted 9 lines
Then I hit a 10s timeout in the gadget when performing a display modeset operation (wait on missing vblank). The result of this was that the host timed out and moved on. The gadget however didn't know that the host gave up, so it queued up the status value. The result of this was that all further requests from the host would time out.
Do you know a solution to this?
My work around is to just poll on the status request, which returns a value immediately, until there's a result. The udc driver I use is dwc2.
I have now tried this on a Beaglebone Black (musb udc driver) and it works just fine there (it displays an error message on the next request). So it has to be a dwc2 driver problem. I will try and chase down this problem when I get the time.
This means I don't need this status request polling in my host driver.
Noralf.
Hi Noralf,
Quoted 5 lines · Noralf Trønnes
I would like to keep the
SET_BUFFERrequest since it will serve as a syncing point between the host and the device. I'm no USB expert but I assume that a bulk transfer can fail halfway through and result in the next update starting where the previous one failed and thus writing beyond the end of the display buffer.
Transfers either succeed completely (possibly after many retries), time out (after zero or more transfered bytes) or fail catastrophically (e.g. from device disconnect).
In all cases, the driver on the host knows/has available how many bytes were successfully transfered.
//Peter
Den 14.07.2020 19.40, skrev Peter Stuge:
Quoted 9 lines
Hi Noralf,
Quoted 5 lines · Noralf Trønnes
I would like to keep the
SET_BUFFERrequest since it will serve as a syncing point between the host and the device. I'm no USB expert but I assume that a bulk transfer can fail halfway through and result in the next update starting where the previous one failed and thus writing beyond the end of the display buffer.
Quoted 7 lines
Transfers either succeed completely (possibly after many retries), time out (after zero or more transfered bytes) or fail catastrophically (e.g. from device disconnect).
In all cases, the driver on the host knows/has available how many bytes were successfully transfered.
I was thinking about the device, that it could get out of sync. Let's say the host sends a 1k framebuffer and half of it gets transferred and the rest fails for some reason. Lubomir's MCU implementation has an endpoint max size of 64 bytes and a callback is called for each packet. If the 1k transfer fails at some point, will the device be able to detect this and know that the next time the rx callback is called that this is the start of a new framebuffer update?
Noralf.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 10 lines · Noralf Trønnes
Quoted 2 lines
In all cases, the driver on the host knows/has available how many bytes were successfully transfered.
I was thinking about the device, that it could get out of sync. Let's say the host sends a 1k framebuffer and half of it gets transferred and the rest fails for some reason. Lubomir's MCU implementation has an endpoint max size of 64 bytes and a callback is called for each packet. If the 1k transfer fails at some point, will the device be able to detect this and know that the next time the rx callback is called that this is the start of a new framebuffer update?
Ah! No, a device can not detect that the host intended to send more (bulk) packets but e.g. timed out.
I can't immediately think of other reasons for a larger transfer to fail, which still allow communication to continue.
When the host recognizes a timeout with partial data transfer it could simply send the remaining data in a new transfer.
While the device can not detect host intent, the protocol could allow devices to specify requirements, e.g. that the host always sends full frames.
In any case, please avoid making a control request mandatory for frame transfer.
Because control requests are scheduled differently onto the wire and because they consist of more packets than bulk data, a control request will interrupt a bulk data stream and likely introduce unneccessary latency.
If synchronization is always required then I'd suggest to place it inline with frame data, e.g. in the first packet byte.
If synchronization is only required in rare cases then a control transfer is probably the better choice, to not waste any inline bytes.
But the optimum would be that the device can describe its needs to the host and the host driver ensures that the device always receives the data it needs.
Do you think this is possible?
Kind regards
//Peter
Quoted 16 lines · Noralf Trønnes
Den 14.07.2020 19.40, skrev Peter Stuge:
Quoted 13 lines
Hi Noralf,
Quoted 5 lines · Noralf Trønnes
I would like to keep the
SET_BUFFERrequest since it will serve as a syncing point between the host and the device. I'm no USB expert but I assume that a bulk transfer can fail halfway through and result in the next update starting where the previous one failed and thus writing beyond the end of the display buffer.Transfers either succeed completely (possibly after many retries), time out (after zero or more transfered bytes) or fail catastrophically (e.g. from device disconnect).
Quoted 8 lines
Quoted 3 lines
In all cases, the driver on the host knows/has available how many bytes were successfully transfered.
I was thinking about the device, that it could get out of sync. Let's say the host sends a 1k framebuffer and half of it gets transferred and the rest fails for some reason. Lubomir's MCU implementation has an endpoint max size of 64 bytes and a callback is called for each packet.
Note that 64 bytes was chosen totally arbitrarily, without any thought. Perhaps the full frame of 1024 bytes would work just fine. I'm not familiar with USB at all.
Quoted 5 lines
If the 1k transfer fails at some point, will the device be able to detect this and know that the next time the rx callback is called that this is the start of a new framebuffer update?
Noralf.
Lubo
Den 14.07.2020 21.38, skrev Peter Stuge:
Quoted 35 lines
Quoted 10 lines · Noralf Trønnes
Quoted 2 lines
In all cases, the driver on the host knows/has available how many bytes were successfully transfered.
I was thinking about the device, that it could get out of sync. Let's say the host sends a 1k framebuffer and half of it gets transferred and the rest fails for some reason. Lubomir's MCU implementation has an endpoint max size of 64 bytes and a callback is called for each packet. If the 1k transfer fails at some point, will the device be able to detect this and know that the next time the rx callback is called that this is the start of a new framebuffer update?
Ah! No, a device can not detect that the host intended to send more (bulk) packets but e.g. timed out.
I can't immediately think of other reasons for a larger transfer to fail, which still allow communication to continue.
When the host recognizes a timeout with partial data transfer it could simply send the remaining data in a new transfer.
While the device can not detect host intent, the protocol could allow devices to specify requirements, e.g. that the host always sends full frames.
In any case, please avoid making a control request mandatory for frame transfer.
Because control requests are scheduled differently onto the wire and because they consist of more packets than bulk data, a control request will interrupt a bulk data stream and likely introduce unneccessary latency.
If synchronization is always required then I'd suggest to place it inline with frame data, e.g. in the first packet byte.
Quoted 8 lines
If synchronization is only required in rare cases then a control transfer is probably the better choice, to not waste any inline bytes.
But the optimum would be that the device can describe its needs to the host and the host driver ensures that the device always receives the data it needs.
Do you think this is possible?
Looking at the host driver I see that I need to fix it so that it requeues the update if it fails (on SET_BUFFER or bulk out). Currently it just goes back to sleep waiting for userspace to announce a new change.
I would like to avoid having a special case for retrying the failing part of a bulk transfer for devices that only want full updates, I would prefer to use the common error path of retrying the whole update.
This is my suggestion for the new flag:
/*
* Always send the entire framebuffer when flushing changes.
* The GUD_DRM_USB_REQ_SET_BUFFER request will not be sent before each
bulk transfer,
* it will only be sent if the previous bulk transfer had failed. This
is done to
* inform the device that the previous update failed and that a new one
is started.
*
* This flag can not be used in combination with compression. */
#define GUD_DRM_DISPLAY_FLAG_FULL_UPDATE BIT(1)
Noralf.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel