media: uvcvideo: Implement the Privacy GPIO as a evdev
Subsystems (4)
v5 cover media: uvcvideo: Implement the Privacy GPIO as a evdev
Some notebooks have a button to disable the camera (not to be mistaken with the mechanical cover). This is a standard GPIO linked to the camera via the ACPI table.
4 years ago we added support for this button in UVC via the Privacy control. This has three issues:
- If the camera has its own privacy control, it will be masked.
- We need to power-up the camera to read the privacy control gpio.
- Other drivers have not followed this approach and have used evdev.
We fixed the power-up isses with "granular power saving", but the other issues are still open.
This patchset implements the Privacy GPIO as a evdev.
---
Changes in v5:
- Drop UVC_GUID_EXT_GPIO_CONTROLLER
- Remove merged patches and patches that will conflict with uvc-rotation
- Rebase
- Link to v4: https://lore.kernel.org/r/[email protected]
Changes in v4:
- Remove gpio entity, it is not needed.
- Use unit->gpio.irq in free_irq to make smatch happy.
- Link to v3: https://lore.kernel.org/r/[email protected]
Changes in v3:
- CodeStyle (Thanks Sakari)
- Re-implement as input device
- Make the code depend on UVC_INPUT_EVDEV
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Rebase on top of https://patchwork.linuxtv.org/project/linux-media/patch/[email protected]/
- Create uvc_gpio_cleanup and uvc_gpio_deinit
- Refactor quirk: do not disable irq
- Change define number for MEDIA_ENT_F_GPIO
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Ricardo Ribalda (5):
media: uvcvideo: Factor out gpio functions to its own file
media: uvcvideo: Re-implement privacy GPIO as an input device
media: uvcvideo: Introduce UVC_QUIRK_PRIVACY_DURING_STREAM
media: uvcvideo: Make gpio_unit entity-less
media: uvcvideo: Remove UVC_EXT_GPIO entity
drivers/media/usb/uvc/Kconfig | 2 +- drivers/media/usb/uvc/Makefile | 3 + drivers/media/usb/uvc/uvc_ctrl.c | 20 ------ drivers/media/usb/uvc/uvc_driver.c | 135 ++--------------------------------- drivers/media/usb/uvc/uvc_entity.c | 1 - drivers/media/usb/uvc/uvc_gpio.c | 139 +++++++++++++++++++++++++++++++++++++ drivers/media/usb/uvc/uvc_status.c | 13 +++- drivers/media/usb/uvc/uvc_video.c | 4 ++ drivers/media/usb/uvc/uvcvideo.h | 38 ++++++---- include/linux/usb/uvc.h | 3 - 10 files changed, 185 insertions(+), 173 deletions(-)
---
base-commit: d968e50b5c26642754492dea23cbd3592bde62d8
change-id: 20241030-uvc-subdev-89f4467a00b5
Best regards,
Signature · 1 line
Ricardo Ribalda <[email protected]>
PATCH v5 1/5 media: uvcvideo: Factor out gpio functions to its own file
This is just a refactor patch, no new functionality is added.
--- drivers/media/usb/uvc/Makefile | 3 +- drivers/media/usb/uvc/uvc_driver.c | 121 +----------------------------------- drivers/media/usb/uvc/uvc_gpio.c | 122 +++++++++++++++++++++++++++++++++++++ drivers/media/usb/uvc/uvcvideo.h | 7 +++ 4 files changed, 133 insertions(+), 120 deletions(-)
drivers/media/usb/uvc/Makefile +2 -1
@@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 uvcvideo-objs := uvc_driver.o uvc_queue.o uvc_v4l2.o uvc_video.o uvc_ctrl.o \ - uvc_status.o uvc_isight.o uvc_debugfs.o uvc_metadata.o + uvc_status.o uvc_isight.o uvc_debugfs.o uvc_metadata.o \ + uvc_gpio.o ifeq ($(CONFIG_MEDIA_CONTROLLER),y) uvcvideo-objs += uvc_entity.o endif
drivers/media/usb/uvc/uvc_driver.c +2 -119
139 lines not on this page · raw message
drivers/media/usb/uvc/uvc_gpio.c new file +122 -0
122 lines not on this page · raw message
drivers/media/usb/uvc/uvcvideo.h +7 -0
@@ -688,6 +688,8 @@ do { \*/ struct uvc_entity *uvc_entity_by_id (struct uvc_device *dev,int id); +struct uvc_entity *uvc_alloc_entity (u16 type,u16 id,unsigned int num_pads, +unsigned int extra_size);/* Video buffers queue management. */ int uvc_queue_init (struct uvc_video_queue *queue,enum v4l2_buf_type type);
@@ -814,4 +816,9 @@ void uvc_debugfs_cleanup_stream(struct uvc_streaming *stream);size_t uvc_video_stats_dump (struct uvc_streaming *stream,char *buf,size_t size); +/* gpio */ +int uvc_gpio_parse (struct uvc_device *dev); +int uvc_gpio_init_irq (struct uvc_device *dev); +void uvc_gpio_deinit (struct uvc_device *dev); +#endif
Signature · 1 line
2.50.0.727.gbf7dc18ff4-goog
PATCH v5 2/5 media: uvcvideo: Re-implement privacy GPIO as an input device
In reply to Ricardo RibaldaReimplement privacy GPIO as an input device.
This is an attempt to unify how we notify userspace about a camera that is covered.
Replace the previous V4L2_CID_PRIVACY control with evdev SW_CAMERA_LENS_COVER.
This has some main benefits:
- It unifies behaviour with other drivers.
- It allows reading the privacy events without powering up the camera.
- It allows reading the privacy gpio and the internal gpio control (if present).
Although this introduces an ABI change, we have only seen ChromeOS using this feature.
--- drivers/media/usb/uvc/Kconfig | 2 +- drivers/media/usb/uvc/Makefile | 6 ++-- drivers/media/usb/uvc/uvc_ctrl.c | 20 ----------- drivers/media/usb/uvc/uvc_driver.c | 3 +- drivers/media/usb/uvc/uvc_gpio.c | 72 +++++++++++++------------------------- drivers/media/usb/uvc/uvc_status.c | 13 +++++-- drivers/media/usb/uvc/uvcvideo.h | 15 +++++--- 7 files changed, 51 insertions(+), 80 deletions(-)
drivers/media/usb/uvc/Kconfig +1 -1
@@ -17,6 +17,6 @@ config USB_VIDEO_CLASS_INPUT_EVDEV depends on USB_VIDEO_CLASS=INPUT || INPUT=y help This option makes USB Video Class devices register an input device - to report button events. + to report button events and privacy GPIO. If you are in doubt, say Y.
drivers/media/usb/uvc/Makefile +4 -2
@@ -1,8 +1,10 @@ # SPDX-License-Identifier: GPL-2.0 uvcvideo-objs := uvc_driver.o uvc_queue.o uvc_v4l2.o uvc_video.o uvc_ctrl.o \ - uvc_status.o uvc_isight.o uvc_debugfs.o uvc_metadata.o \ - uvc_gpio.o + uvc_status.o uvc_isight.o uvc_debugfs.o uvc_metadata.o ifeq ($(CONFIG_MEDIA_CONTROLLER),y) uvcvideo-objs += uvc_entity.o endif +ifeq ($(CONFIG_USB_VIDEO_CLASS_INPUT_EVDEV),y) +uvcvideo-objs += uvc_gpio.o +endif obj-$(CONFIG_USB_VIDEO_CLASS) += uvcvideo.o
drivers/media/usb/uvc/uvc_ctrl.c +0 -20
@@ -350,14 +350,6 @@ static const struct uvc_control_info uvc_ctrls[] = { | UVC_CTRL_FLAG_RESTORE | UVC_CTRL_FLAG_AUTO_UPDATE, }, - { - .entity = UVC_GUID_EXT_GPIO_CONTROLLER, - .selector = UVC_CT_PRIVACY_CONTROL, - .index = 0, - .size = 1, - .flags =UVC_CTRL_FLAG_GET_CUR - | UVC_CTRL_FLAG_AUTO_UPDATE, - },/* * UVC_CTRL_FLAG_AUTO_UPDATE is needed because the RoI may get updated * by sensors.
@@ -939,15 +931,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { .v4l2_type = V4L2_CTRL_TYPE_BOOLEAN, .data_type = UVC_CTRL_DATA_TYPE_BOOLEAN, }, - { - .id = V4L2_CID_PRIVACY, - .entity = UVC_GUID_EXT_GPIO_CONTROLLER, - .selector = UVC_CT_PRIVACY_CONTROL, - .size = 1, - .offset = 0, - .v4l2_type = V4L2_CTRL_TYPE_BOOLEAN, - .data_type = UVC_CTRL_DATA_TYPE_BOOLEAN, - }, { .entity = UVC_GUID_UVC_PROCESSING, .selector = UVC_PU_POWER_LINE_FREQUENCY_CONTROL,
@@ -3252,9 +3235,6 @@ static int uvc_ctrl_init_chain(struct uvc_video_chain *chain) }else if (UVC_ENTITY_TYPE (entity) ==UVC_ITT_CAMERA ) { bmControls = entity->camera.bmControls; bControlSize = entity->camera.bControlSize; - }else if (UVC_ENTITY_TYPE (entity) ==UVC_EXT_GPIO_UNIT ) { - bmControls = entity->gpio.bmControls; - bControlSize = entity->gpio.bControlSize; }/* Remove bogus/blacklisted controls */
drivers/media/usb/uvc/uvc_driver.c +2 -1
@@ -2158,6 +2158,7 @@ static int uvc_probe(struct usb_interface *intf,if (ret <0 ) goto error;#endif +/* Save our data pointer in the interface data. */ usb_set_intfdata (intf, dev);
@@ -2169,7 +2170,7 @@ static int uvc_probe(struct usb_interface *intf, ret); } - ret =uvc_gpio_init_irq (dev); + ret =uvc_gpio_init (dev);if (ret <0 ) {dev_err (&dev->udev->dev,"Unable to request privacy GPIO IRQ (%d)\n" , ret);
drivers/media/usb/uvc/uvc_gpio.c +24 -48
116 lines not on this page · raw message
drivers/media/usb/uvc/uvc_status.c +10 -3
@@ -44,7 +44,7 @@ static int uvc_input_init(struct uvc_device *dev)struct input_dev *input;int ret; -if (!uvc_input_has_button (dev)) +if (!uvc_input_has_button (dev) && !dev->gpio_unit)return 0 ; input =input_allocate_device ();
@@ -59,8 +59,15 @@ static int uvc_input_init(struct uvc_device *dev)usb_to_input_id (dev->udev, &input->id); input->dev.parent = &dev->intf->dev; -__set_bit (EV_KEY , input->evbit); -__set_bit (KEY_CAMERA , input->keybit); +if (uvc_input_has_button (dev)) { +__set_bit (EV_KEY , input->evbit); +__set_bit (KEY_CAMERA , input->keybit); + } + +if (dev->gpio_unit) { +__set_bit (EV_SW , input->evbit); +__set_bit (SW_CAMERA_LENS_COVER , input->swbit); + }if ((ret =input_register_device (input)) <0 ) goto error;
drivers/media/usb/uvc/uvcvideo.h +10 -5
@@ -15,6 +15,7 @@#include <linux/videodev2.h> #include <linux/workqueue.h> #include <media/media-device.h> +#include <media/v4l2-ctrls.h> #include <media/v4l2-device.h> #include <media/v4l2-event.h> #include <media/v4l2-fh.h>
@@ -238,12 +239,10 @@ struct uvc_entity {u8 *bmControlsType; } extension; -struct { -u8 bControlSize; -u8 *bmControls; -struct gpio_desc *gpio_privacy; +struct uvc_gpio {int irq;bool initialized; +struct gpio_desc *gpio_privacy; } gpio; };
@@ -817,8 +816,14 @@ size_t uvc_video_stats_dump(struct uvc_streaming *stream, char *buf, size_t size);/* gpio */ +#ifdef CONFIG_USB_VIDEO_CLASS_INPUT_EVDEV int uvc_gpio_parse (struct uvc_device *dev); -int uvc_gpio_init_irq (struct uvc_device *dev); +int uvc_gpio_init (struct uvc_device *dev);void uvc_gpio_deinit (struct uvc_device *dev); +#else +static inline int uvc_gpio_parse (struct uvc_device *dev) {return 0 ; } +static inline int uvc_gpio_init (struct uvc_device *dev) {return 0 ; } +static inline void uvc_gpio_deinit (struct uvc_device *dev) {}; +#endif #endif
Signature · 1 line
2.50.0.727.gbf7dc18ff4-goog
PATCH v5 3/5 media: uvcvideo: Introduce UVC_QUIRK_PRIVACY_DURING_STREAM
In reply to Ricardo RibaldaSome devices power the GPIO pull-up with the same power-supply as the camera. Avoid reading the GPIO if the device is not streaming.
--- drivers/media/usb/uvc/uvc_gpio.c | 58 ++++++++++++++++++++++++++++++++++++--- drivers/media/usb/uvc/uvc_video.c | 4 +++ drivers/media/usb/uvc/uvcvideo.h | 4 +++ 3 files changed, 62 insertions(+), 4 deletions(-)
drivers/media/usb/uvc/uvc_gpio.c +54 -4
@@ -5,6 +5,7 @@* Copyright 2024 Google LLC */ +#include <linux/dmi.h> #include <linux/kernel.h> #include <linux/gpio/consumer.h> #include <linux/input.h>
@@ -16,6 +17,9 @@ static irqreturn_t uvc_gpio_irq(int irq, void *data)struct uvc_gpio *uvc_gpio = &dev->gpio_unit->gpio;int new_val; +if (!uvc_gpio->gpio_ready) +return IRQ_HANDLED ; + new_val =gpiod_get_value_cansleep (uvc_gpio->gpio_privacy);if (new_val <0 )return IRQ_HANDLED ;
@@ -26,6 +30,24 @@ static irqreturn_t uvc_gpio_irq(int irq, void *data)return IRQ_HANDLED ; } +static const struct dmi_system_id privacy_valid_during_streamon[] = { + { + .ident ="HP Elite c1030 Chromebook" , + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"HP" ), +DMI_MATCH (DMI_PRODUCT_NAME ,"Jinlon" ), + }, + }, + { + .ident ="HP Pro c640 Chromebook" , + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"HP" ), +DMI_MATCH (DMI_PRODUCT_NAME ,"Dratini" ), + }, + }, + { }/* terminate list */ +}; +int uvc_gpio_parse (struct uvc_device *dev) {struct gpio_desc *gpio_privacy;
@@ -51,6 +73,15 @@ int uvc_gpio_parse(struct uvc_device *dev)if (!unit)return -ENOMEM ; +/* +* Note: This quirk will not match external UVC cameras, +* as they will not have the corresponding ACPI GPIO entity. +*/ +if (dmi_check_system (privacy_valid_during_streamon)) + dev->quirks |=UVC_QUIRK_PRIVACY_DURING_STREAM ; +else + unit->gpio.gpio_ready = true; + unit->gpio.gpio_privacy = gpio_privacy; unit->gpio.irq = irq;strscpy (unit->name,"GPIO" ,sizeof (unit->name));
@@ -61,6 +92,16 @@ int uvc_gpio_parse(struct uvc_device *dev)return 0 ; } +void uvc_gpio_quirk (struct uvc_device *dev,bool stream_on) +{ +if (!dev->gpio_unit || !(dev->quirks &UVC_QUIRK_PRIVACY_DURING_STREAM )) +return ; + + dev->gpio_unit->gpio.gpio_ready = stream_on; +if (stream_on) +uvc_gpio_irq (0 , dev); +} +int uvc_gpio_init (struct uvc_device *dev) {struct uvc_entity *unit = dev->gpio_unit;
@@ -70,10 +111,6 @@ int uvc_gpio_init(struct uvc_device *dev)if (!unit || unit->gpio.irq <0 )return 0 ; - init_val =gpiod_get_value_cansleep (unit->gpio.gpio_privacy); -if (init_val <0 ) -return init_val; - ret = request_threaded_irq(unit->gpio.irq, NULL, uvc_gpio_irq, IRQF_ONESHOT | IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
@@ -81,6 +118,19 @@ int uvc_gpio_init(struct uvc_device *dev)if (ret)return ret; +if ((dev->quirks &UVC_QUIRK_PRIVACY_DURING_STREAM )) { +uvc_gpio_quirk (dev, false); + init_val = false; + }else { + unit->gpio.gpio_ready = true; + + init_val =gpiod_get_value_cansleep (unit->gpio.gpio_privacy); +if (init_val <0 ) { +free_irq (unit->gpio.irq, dev); +return init_val; + } + } +input_report_switch (dev->input,SW_CAMERA_LENS_COVER , init_val);input_sync (dev->input);
drivers/media/usb/uvc/uvc_video.c +4 -0
@@ -2356,6 +2356,8 @@ int uvc_video_start_streaming(struct uvc_streaming *stream)if (ret <0 ) goto error_video; +uvc_gpio_quirk (stream->dev, true); +return 0 ; error_video:
@@ -2368,6 +2370,8 @@ int uvc_video_start_streaming(struct uvc_streaming *stream)void uvc_video_stop_streaming (struct uvc_streaming *stream) { +uvc_gpio_quirk (stream->dev, false); +uvc_video_stop_transfer (stream,1 );if (stream->intf->num_altsetting >1 ) {
drivers/media/usb/uvc/uvcvideo.h +4 -0
@@ -79,6 +79,7 @@#define UVC_QUIRK_INVALID_DEVICE_SOF 0x00010000#define UVC_QUIRK_MJPEG_NO_EOF 0x00020000#define UVC_QUIRK_MSXU_META 0x00040000 +#define UVC_QUIRK_PRIVACY_DURING_STREAM 0x00080000/* Format flags */ #define UVC_FMT_FLAG_COMPRESSED 0x00000001
@@ -242,6 +243,7 @@ struct uvc_entity {struct uvc_gpio {int irq;bool initialized; +bool gpio_ready;struct gpio_desc *gpio_privacy; } gpio; };
@@ -820,10 +822,12 @@ size_t uvc_video_stats_dump(struct uvc_streaming *stream, char *buf,int uvc_gpio_parse (struct uvc_device *dev);int uvc_gpio_init (struct uvc_device *dev);void uvc_gpio_deinit (struct uvc_device *dev); +void uvc_gpio_quirk (struct uvc_device *dev,bool stream_on);#else static inline int uvc_gpio_parse (struct uvc_device *dev) {return 0 ; }static inline int uvc_gpio_init (struct uvc_device *dev) {return 0 ; }static inline void uvc_gpio_deinit (struct uvc_device *dev) {}; +static inline void uvc_gpio_quirk (struct uvc_device *dev,bool stream_on) {};#endif #endif
Signature · 1 line
2.50.0.727.gbf7dc18ff4-goog
PATCH v5 4/5 media: uvcvideo: Make gpio_unit entity-less
In reply to Ricardo RibaldaNow that we do not need to export a control there is no need to create an entity. Move the uvc_gpio structure to uvc_device.
--- drivers/media/usb/uvc/uvc_driver.c | 7 ------- drivers/media/usb/uvc/uvc_gpio.c | 39 +++++++++++++++----------------------- drivers/media/usb/uvc/uvc_status.c | 4 ++-- drivers/media/usb/uvc/uvcvideo.h | 2 +- 4 files changed, 18 insertions(+), 34 deletions(-)
drivers/media/usb/uvc/uvc_driver.c +0 -7
@@ -1755,13 +1755,6 @@ static int uvc_scan_device(struct uvc_device *dev)return -ENODEV ; } -/* Add GPIO entity to the first chain. */ -if (dev->gpio_unit) { - chain =list_first_entry (&dev->chains, - struct uvc_video_chain, list); -list_add_tail (&dev->gpio_unit->chain, &chain->entities); - } -return 0 ; }
drivers/media/usb/uvc/uvc_gpio.c +15 -24
@@ -14,7 +14,7 @@static irqreturn_t uvc_gpio_irq (int irq,void *data) {struct uvc_device *dev = data; -struct uvc_gpio *uvc_gpio = &dev->gpio_unit->gpio; +struct uvc_gpio *uvc_gpio = &dev->gpio_unit;int new_val;if (!uvc_gpio->gpio_ready)
@@ -51,7 +51,6 @@ static const struct dmi_system_id privacy_valid_during_streamon[] = {int uvc_gpio_parse (struct uvc_device *dev) {struct gpio_desc *gpio_privacy; -struct uvc_entity *unit;int irq; gpio_privacy = devm_gpiod_get_optional(&dev->intf->dev, "privacy",
@@ -69,10 +68,6 @@ int uvc_gpio_parse(struct uvc_device *dev)return dev_err_probe (&dev->intf->dev, irq,"No IRQ for privacy GPIO\n" ); - unit =uvc_alloc_entity (UVC_EXT_GPIO_UNIT ,UVC_EXT_GPIO_UNIT_ID ,0 ,1 ); -if (!unit) -return -ENOMEM ; -/* * Note: This quirk will not match external UVC cameras, * as they will not have the corresponding ACPI GPIO entity.
@@ -80,38 +75,33 @@ int uvc_gpio_parse(struct uvc_device *dev)if (dmi_check_system (privacy_valid_during_streamon)) dev->quirks |=UVC_QUIRK_PRIVACY_DURING_STREAM ;else - unit->gpio.gpio_ready = true; - - unit->gpio.gpio_privacy = gpio_privacy; - unit->gpio.irq = irq; -strscpy (unit->name,"GPIO" ,sizeof (unit->name)); -list_add_tail (&unit->list, &dev->entities); + dev->gpio_unit.gpio_ready = true; - dev->gpio_unit = unit; + dev->gpio_unit.gpio_privacy = gpio_privacy; + dev->gpio_unit.irq = irq;return 0 ; }void uvc_gpio_quirk (struct uvc_device *dev,bool stream_on) { -if (!dev->gpio_unit || !(dev->quirks &UVC_QUIRK_PRIVACY_DURING_STREAM )) +if (!(dev->quirks &UVC_QUIRK_PRIVACY_DURING_STREAM ))return ; - dev->gpio_unit->gpio.gpio_ready = stream_on; + dev->gpio_unit.gpio_ready = stream_on;if (stream_on)uvc_gpio_irq (0 , dev); }int uvc_gpio_init (struct uvc_device *dev) { -struct uvc_entity *unit = dev->gpio_unit;int init_val;int ret; -if (!unit || unit->gpio.irq <0 ) +if (!dev->gpio_unit.gpio_privacy)return 0 ; - ret =request_threaded_irq (unit->gpio.irq,NULL , uvc_gpio_irq, + ret =request_threaded_irq (dev->gpio_unit.irq,NULL , uvc_gpio_irq,IRQF_ONESHOT |IRQF_TRIGGER_FALLING |IRQF_TRIGGER_RISING ,"uvc_privacy_gpio" , dev);
@@ -122,11 +112,12 @@ int uvc_gpio_init(struct uvc_device *dev)uvc_gpio_quirk (dev, false); init_val = false; }else { - unit->gpio.gpio_ready = true; + dev->gpio_unit.gpio_ready = true; - init_val =gpiod_get_value_cansleep (unit->gpio.gpio_privacy); + init_val = +gpiod_get_value_cansleep (dev->gpio_unit.gpio_privacy);if (init_val <0 ) { -free_irq (unit->gpio.irq, dev); +free_irq (dev->gpio_unit.irq, dev);return init_val; } }
@@ -134,15 +125,15 @@ int uvc_gpio_init(struct uvc_device *dev)input_report_switch (dev->input,SW_CAMERA_LENS_COVER , init_val);input_sync (dev->input); - unit->gpio.initialized = true; + dev->gpio_unit.initialized = true;return 0 ; }void uvc_gpio_deinit (struct uvc_device *dev) { -if (!dev->gpio_unit || !dev->gpio_unit->gpio.initialized) +if (!dev->gpio_unit.initialized)return ; -free_irq (dev->gpio_unit->gpio.irq, dev); +free_irq (dev->gpio_unit.irq, dev); }
drivers/media/usb/uvc/uvc_status.c +2 -2
@@ -44,7 +44,7 @@ static int uvc_input_init(struct uvc_device *dev)struct input_dev *input;int ret; -if (!uvc_input_has_button (dev) && !dev->gpio_unit) +if (!uvc_input_has_button (dev) && !dev->gpio_unit.gpio_privacy)return 0 ; input =input_allocate_device ();
@@ -64,7 +64,7 @@ static int uvc_input_init(struct uvc_device *dev)__set_bit (KEY_CAMERA , input->keybit); } -if (dev->gpio_unit) { +if (dev->gpio_unit.gpio_privacy) {__set_bit (EV_SW , input->evbit);__set_bit (SW_CAMERA_LENS_COVER , input->swbit); }
drivers/media/usb/uvc/uvcvideo.h +1 -1
@@ -628,7 +628,7 @@ struct uvc_device {const void *data; } async_ctrl; -struct uvc_entity *gpio_unit; +struct uvc_gpio gpio_unit; };struct uvc_fh {
Signature · 1 line
2.50.0.727.gbf7dc18ff4-goog
PATCH v5 5/5 media: uvcvideo: Remove UVC_EXT_GPIO entity
In reply to Ricardo RibaldaThe only implementation of this entity was the external privacy gpio, which now does not require to emulate an entity.
Remove all the dead code.
--- drivers/media/usb/uvc/uvc_driver.c | 4 ---- drivers/media/usb/uvc/uvc_entity.c | 1 - drivers/media/usb/uvc/uvcvideo.h | 20 +++++++------------- include/linux/usb/uvc.h | 3 --- 4 files changed, 7 insertions(+), 21 deletions(-)
drivers/media/usb/uvc/uvc_driver.c +0 -4
@@ -789,7 +789,6 @@ static int uvc_parse_streaming(struct uvc_device *dev, }static const u8 uvc_camera_guid[16 ] =UVC_GUID_UVC_CAMERA ; -static const u8 uvc_gpio_guid[16 ] =UVC_GUID_EXT_GPIO_CONTROLLER ;static const u8 uvc_media_transport_input_guid[16 ] =UVC_GUID_UVC_MEDIA_TRANSPORT_INPUT ;static const u8 uvc_processing_guid[16 ] =UVC_GUID_UVC_PROCESSING ;
@@ -821,9 +820,6 @@ struct uvc_entity *uvc_alloc_entity(u16 type, u16 id, unsigned int num_pads,* is initialized by the caller. */ switch (type) { -case UVC_EXT_GPIO_UNIT : -memcpy (entity->guid, uvc_gpio_guid,16 ); -break ;case UVC_ITT_CAMERA :memcpy (entity->guid, uvc_camera_guid,16 );break ;
drivers/media/usb/uvc/uvc_entity.c +0 -1
@@ -105,7 +105,6 @@ static int uvc_mc_init_entity(struct uvc_video_chain *chain,case UVC_OTT_DISPLAY :case UVC_OTT_MEDIA_TRANSPORT_OUTPUT :case UVC_EXTERNAL_VENDOR_SPECIFIC : -case UVC_EXT_GPIO_UNIT :default : function =MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN ;break ;
drivers/media/usb/uvc/uvcvideo.h +7 -13
@@ -39,9 +39,6 @@ (UVC_ENTITY_IS_TERM (entity) && \ ((entity)->type &0x8000 ) ==UVC_TERM_OUTPUT ) -#define UVC_EXT_GPIO_UNIT 0x7ffe -#define UVC_EXT_GPIO_UNIT_ID 0x100 -/* ------------------------------------------------------------------------ * Driver specific constants. */
@@ -189,8 +186,7 @@ struct uvc_entity {/* * Entities exposed by the UVC device use IDs 0-255, extra entities -* implemented by the driver (such as the GPIO entity) use IDs 256 and -* up. +* implemented by the driver use IDs 256 and up. */ u16 id;u16 type;
@@ -239,13 +235,6 @@ struct uvc_entity {u8 *bmControls;u8 *bmControlsType; } extension; - -struct uvc_gpio { -int irq; -bool initialized; -bool gpio_ready; -struct gpio_desc *gpio_privacy; - } gpio; };u8 bNrInPins;
@@ -628,7 +617,12 @@ struct uvc_device {const void *data; } async_ctrl; -struct uvc_gpio gpio_unit; +struct uvc_gpio { +int irq; +bool initialized; +bool gpio_ready; +struct gpio_desc *gpio_privacy; + } gpio_unit; };struct uvc_fh {
include/linux/usb/uvc.h +0 -3
@@ -26,9 +26,6 @@#define UVC_GUID_UVC_SELECTOR \ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02} -#define UVC_GUID_EXT_GPIO_CONTROLLER \ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03}#define UVC_GUID_MSXU_1_5 \ {0xdc, 0x95, 0x3f, 0x0f, 0x32, 0x26, 0x4e, 0x4c, \ 0x92, 0xc9, 0xa0, 0x47, 0x82, 0xf4, 0x3b, 0xc8}
Signature · 1 line
2.50.0.727.gbf7dc18ff4-goog