Show privacy_gpio as a v4l2_ctrl
Subsystems (2)
v3 cover Show privacy_gpio as a v4l2_ctrl
Some devices can implement a physical switch to disable the input of the camera on demand. Think of it like an elegant privacy sticker.
The system can read the status of the privacy switch via a GPIO.
The ACPI table maps this GPIO to the USB device via _CRS and _DSD descriptors, so the kernel can find it.
The userspace applications need to know if the privacy pin is enabled or not.
The obvious way to show it to userspace is via the V4L2_CID_PRIVACY control.
This patchset implement this functionality.
v2: Thanks to all the comments from Joe Perches
- Rework of printk macros
v2: Thanks to all the comments from Laurent!
- move guid to unit
- support entities with no pads
- CodeStyle
- Irq handling
- pr_cont
- new ids
Ricardo Ribalda (8):
media: uvcvideo: Move guid to entity
media: uvcvideo: Allow external entities
media: uvcvideo: Allow entities with no pads
media: uvcvideo: Entity defined get_info and get_cur
media: uvcvideo: Implement UVC_EXT_GPIO_UNIT
media: uvcvideo: Add Privacy control based on EXT_GPIO
media: uvcvideo: Use dev_ printk aliases
media: uvcvideo: New macro uvc_trace_cont
drivers/media/usb/uvc/uvc_ctrl.c | 80 +++++---- drivers/media/usb/uvc/uvc_driver.c | 249 +++++++++++++++++++++-------- drivers/media/usb/uvc/uvc_entity.c | 10 +- drivers/media/usb/uvc/uvc_status.c | 13 +- drivers/media/usb/uvc/uvc_video.c | 51 +++--- drivers/media/usb/uvc/uvcvideo.h | 52 ++++-- 6 files changed, 309 insertions(+), 146 deletions(-)
Signature · 1 line
2.29.2.299.gdc1121823c-goog
PATCH v3 1/8 media: uvcvideo: Move guid to entity
Instead of having multiple copies of the entity guid on the code, move it to the entity structure.
--- drivers/media/usb/uvc/uvc_ctrl.c | 30 ++++-------------------------- drivers/media/usb/uvc/uvc_driver.c | 26 ++++++++++++++++++++++++-- drivers/media/usb/uvc/uvcvideo.h | 2 +- 3 files changed, 29 insertions(+), 29 deletions(-)
drivers/media/usb/uvc/uvc_ctrl.c +4 -26
@@ -826,31 +826,10 @@ static void uvc_set_le_value(struct uvc_control_mapping *mapping,* Terminal and unit management */ -static const u8 uvc_processing_guid[16 ] =UVC_GUID_UVC_PROCESSING ; -static const u8 uvc_camera_guid[16 ] =UVC_GUID_UVC_CAMERA ; -static const u8 uvc_media_transport_input_guid[16 ] = -UVC_GUID_UVC_MEDIA_TRANSPORT_INPUT ; -static int uvc_entity_match_guid (const struct uvc_entity *entity, -const u8 guid[16 ]) +const u8 guid[16 ]) { -switch (UVC_ENTITY_TYPE (entity)) { -case UVC_ITT_CAMERA : -return memcmp (uvc_camera_guid, guid,16 ) ==0 ; - -case UVC_ITT_MEDIA_TRANSPORT_INPUT : -return memcmp (uvc_media_transport_input_guid, guid,16 ) ==0 ; - -case UVC_VC_PROCESSING_UNIT : -return memcmp (uvc_processing_guid, guid,16 ) ==0 ; - -case UVC_VC_EXTENSION_UNIT : -return memcmp (entity->extension.guidExtensionCode, - guid,16 ) ==0 ; - -default : -return 0 ; - } +return memcmp (entity->guid, guid,sizeof (entity->guid)) ==0 ; }/* ------------------------------------------------------------------------
@@ -1776,8 +1755,7 @@ static int uvc_ctrl_fill_xu_info(struct uvc_device *dev,if (data ==NULL )return -ENOMEM ; -memcpy (info->entity, ctrl->entity->extension.guidExtensionCode, -sizeof (info->entity)); +memcpy (info->entity, ctrl->entity->guid,sizeof (info->entity)); info->index = ctrl->index; info->selector = ctrl->index +1 ;
@@ -1883,7 +1861,7 @@ int uvc_xu_ctrl_query(struct uvc_video_chain *chain,if (!found) {uvc_trace (UVC_TRACE_CONTROL ,"Control %pUl/%u not found.\n" , - entity->extension.guidExtensionCode, xqry->selector); + entity->guid, xqry->selector);return -ENOENT ; }
drivers/media/usb/uvc/uvc_driver.c +24 -2
@@ -1019,6 +1019,11 @@ static int uvc_parse_streaming(struct uvc_device *dev,return ret; } +static const u8 uvc_camera_guid[16 ] =UVC_GUID_UVC_CAMERA ; +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 ; +static struct uvc_entity *uvc_alloc_entity (u16 type,u8 id,unsigned int num_pads,unsigned int extra_size) {
@@ -1038,6 +1043,23 @@ static struct uvc_entity *uvc_alloc_entity(u16 type, u8 id, entity->id = id; entity->type = type; + +/* +* Set the GUID for standard entity types. For extension units, the GUID +* is initialized by the caller. +*/ +switch (type) { +case UVC_ITT_CAMERA : +memcpy (entity->guid, uvc_camera_guid,16 ); +break ; +case UVC_ITT_MEDIA_TRANSPORT_INPUT : +memcpy (entity->guid, uvc_media_transport_input_guid,16 ); +break ; +case UVC_VC_PROCESSING_UNIT : +memcpy (entity->guid, uvc_processing_guid,16 ); +break ; + } + entity->num_links =0 ; entity->num_pads = num_pads; entity->pads = ((void *)(entity +1 )) + extra_size;
@@ -1109,7 +1131,7 @@ static int uvc_parse_vendor_control(struct uvc_device *dev,if (unit ==NULL )return -ENOMEM ; -memcpy (unit->extension.guidExtensionCode, &buffer[4 ],16 ); +memcpy (unit->guid, &buffer[4 ],16 ); unit->extension.bNumControls = buffer[20 ];memcpy (unit->baSourceID, &buffer[22 ], p); unit->extension.bControlSize = buffer[22 +p];
@@ -1368,7 +1390,7 @@ static int uvc_parse_standard_control(struct uvc_device *dev,if (unit ==NULL )return -ENOMEM ; -memcpy (unit->extension.guidExtensionCode, &buffer[4 ],16 ); +memcpy (unit->guid, &buffer[4 ],16 ); unit->extension.bNumControls = buffer[20 ];memcpy (unit->baSourceID, &buffer[22 ], p); unit->extension.bControlSize = buffer[22 +p];
drivers/media/usb/uvc/uvcvideo.h +1 -1
@@ -304,6 +304,7 @@ struct uvc_entity {u8 id;u16 type;char name[64 ]; +u8 guid[16 ];/* Media controller-related fields. */ struct video_device *vdev;
@@ -342,7 +343,6 @@ struct uvc_entity { } selector;struct { -u8 guidExtensionCode[16 ];u8 bNumControls;u8 bControlSize;u8 *bmControls;
Signature · 1 line
2.29.2.299.gdc1121823c-goog
PATCH v3 2/8 media: uvcvideo: Allow external entities
In reply to Ricardo RibaldaIncrease the size of the id, to avoid collisions with external entities.
--- drivers/media/usb/uvc/uvc_driver.c | 2 +- drivers/media/usb/uvc/uvcvideo.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/media/usb/uvc/uvc_driver.c +1 -1
@@ -1024,7 +1024,7 @@ 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 ; -static struct uvc_entity *uvc_alloc_entity (u16 type,u8 id, +static struct uvc_entity *uvc_alloc_entity (u16 type,u16 id,unsigned int num_pads,unsigned int extra_size) {struct uvc_entity *entity;
drivers/media/usb/uvc/uvcvideo.h +1 -1
@@ -301,7 +301,7 @@ struct uvc_entity {* chain. */ unsigned int flags; -u8 id; +u16 id;/* 0-255: usb entity. 256-65535: external entities */ u16 type;char name[64 ];u8 guid[16 ];
Signature · 1 line
2.29.2.299.gdc1121823c-goog
PATCH v3 3/8 media: uvcvideo: Allow entities with no pads
In reply to Ricardo RibaldaAvoid an underflow while calculating the number of inputs for entities with zero pads.
--- drivers/media/usb/uvc/uvc_driver.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/media/usb/uvc/uvc_driver.c +6 -2
@@ -1033,7 +1033,11 @@ static struct uvc_entity *uvc_alloc_entity(u16 type, u16 id,unsigned int i; extra_size =roundup (extra_size,sizeof (*entity->pads)); - num_inputs = (type &UVC_TERM_OUTPUT ) ? num_pads : num_pads -1 ; +if (num_pads) + num_inputs = (type &UVC_TERM_OUTPUT ) ? num_pads : + num_pads -1 ; +else + num_inputs =0 ; size =sizeof (*entity) + extra_size +sizeof (*entity->pads) * num_pads + num_inputs; entity =kzalloc (size,GFP_KERNEL );
@@ -1066,7 +1070,7 @@ static struct uvc_entity *uvc_alloc_entity(u16 type, u16 id,for (i =0 ; i < num_inputs; ++i) entity->pads[i].flags =MEDIA_PAD_FL_SINK ; -if (!UVC_ENTITY_IS_OTERM (entity)) +if (!UVC_ENTITY_IS_OTERM (entity) && num_pads) entity->pads[num_pads-1 ].flags =MEDIA_PAD_FL_SOURCE ; entity->bNrInPins = num_inputs;
Signature · 1 line
2.29.2.299.gdc1121823c-goog
PATCH v3 4/8 media: uvcvideo: Entity defined get_info and get_cur
In reply to Ricardo RibaldaAllows controls to get their properties and current value from an entity-defined function instead of via a query to the USB device.
--- drivers/media/usb/uvc/uvc_ctrl.c | 22 ++++++++++++++++++---- drivers/media/usb/uvc/uvcvideo.h | 5 +++++ 2 files changed, 23 insertions(+), 4 deletions(-)
drivers/media/usb/uvc/uvc_ctrl.c +18 -4
@@ -980,10 +980,20 @@ static int __uvc_ctrl_get(struct uvc_video_chain *chain,return -EACCES ;if (!ctrl->loaded) { - ret =uvc_query_ctrl (chain->dev,UVC_GET_CUR , ctrl->entity->id, - chain->dev->intfnum, ctrl->info.selector, +if (ctrl->entity->get_cur) { + ret = ctrl->entity->get_cur (chain->dev, + ctrl->entity, + ctrl->info.selector,uvc_ctrl_data (ctrl,UVC_CTRL_DATA_CURRENT ), ctrl->info.size); + }else { + ret =uvc_query_ctrl (chain->dev,UVC_GET_CUR , + ctrl->entity->id, + chain->dev->intfnum, + ctrl->info.selector, +uvc_ctrl_data (ctrl,UVC_CTRL_DATA_CURRENT ), + ctrl->info.size); + }if (ret <0 )return ret;
@@ -1687,8 +1697,12 @@ static int uvc_ctrl_get_flags(struct uvc_device *dev,if (data ==NULL )return -ENOMEM ; - ret =uvc_query_ctrl (dev,UVC_GET_INFO , ctrl->entity->id, dev->intfnum, - info->selector, data,1 ); +if (ctrl->entity->get_info) + ret = ctrl->entity->get_info (dev, ctrl->entity, + ctrl->info.selector, data); +else + ret =uvc_query_ctrl (dev,UVC_GET_INFO , ctrl->entity->id, + dev->intfnum, info->selector, data,1 );if (!ret) info->flags |= (data[0 ] &UVC_CONTROL_CAP_GET ?UVC_CTRL_FLAG_GET_CUR :0 )
drivers/media/usb/uvc/uvcvideo.h +5 -0
@@ -353,6 +353,11 @@ struct uvc_entity {u8 bNrInPins;u8 *baSourceID; +int (*get_info)(struct uvc_device *dev,struct uvc_entity *entity, +u8 cs,u8 *caps); +int (*get_cur)(struct uvc_device *dev,struct uvc_entity *entity, +u8 cs,void *data,u16 size); +unsigned int ncontrols;struct uvc_control *controls; };
Signature · 1 line
2.29.2.299.gdc1121823c-goog
PATCH v3 5/8 media: uvcvideo: Implement UVC_EXT_GPIO_UNIT
In reply to Ricardo RibaldaSome devices can implement a physical switch to disable the input of the camera on demand. Think of it like an elegant privacy sticker.
The system can read the status of the privacy switch via a GPIO.
It is important to know the status of the switch, e.g. to notify the user when the camera will produce black frames and a videochat application is used.
Since the uvc device is not aware of this pin (and it should't), we need to implement a virtual entity that can interact with such pin.
The location of the GPIO is specified via acpi or DT. on the usb device Eg:
Scope (\_SB.PCI0.XHCI.RHUB.HS07)
{ /.../
Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings
{
GpioIo (Exclusive, PullDefault, 0x0000, 0x0000, IoRestrictionOutputOnly,
"\\_SB.PCI0.GPIO", 0x00, ResourceConsumer, ,
)
{ // Pin list
0x0064
}
})
Name (_DSD, Package (0x02) // _DSD: Device-Specific Data
{
ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301") /* Device Properties for _DSD */,
Package (0x01)
{
Package (0x02)
{
"privacy-gpio",
Package (0x04)
{
\_SB.PCI0.XHCI.RHUB.HS07,
Zero,
Zero,
One
}
}
}
})}
--- drivers/media/usb/uvc/uvc_ctrl.c | 6 ++ drivers/media/usb/uvc/uvc_driver.c | 106 +++++++++++++++++++++++++++++ drivers/media/usb/uvc/uvcvideo.h | 12 ++++ 3 files changed, 124 insertions(+)
drivers/media/usb/uvc/uvc_ctrl.c +6 -0
@@ -1302,6 +1302,9 @@ static void uvc_ctrl_status_event_work(struct work_struct *work)mutex_unlock (&chain->ctrl_mutex); +if (!w->urb) +return ; +/* Resubmit the URB. */ w->urb->interval = dev->int_ep->desc.bInterval; ret =usb_submit_urb (w->urb,GFP_KERNEL );
@@ -2286,6 +2289,9 @@ int uvc_ctrl_init_device(struct uvc_device *dev) }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 +106 -0
148 lines not on this page · raw message
drivers/media/usb/uvc/uvcvideo.h +12 -0
@@ -6,6 +6,7 @@#error "The uvcvideo.h header is deprecated, use linux/uvcvideo.h instead."#endif /* __KERNEL__ */ +#include <linux/gpio/consumer.h> #include <linux/kernel.h> #include <linux/poll.h> #include <linux/usb.h>
@@ -37,6 +38,8 @@ (UVC_ENTITY_IS_TERM (entity) && \ ((entity)->type & 0x8000) == UVC_TERM_OUTPUT) +#define UVC_EXT_GPIO_UNIT 0x7ffe +#define UVC_EXT_GPIO_UNIT_ID 0x100/* ------------------------------------------------------------------------ * GUIDs
@@ -56,6 +59,9 @@#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_FORMAT_MJPEG \ { 'M', 'J', 'P', 'G', 0x00, 0x00, 0x10, 0x00, \
@@ -348,6 +354,12 @@ struct uvc_entity {u8 *bmControls;u8 *bmControlsType; } extension; + +struct { +u8 bControlSize; +u8 *bmControls; +struct gpio_desc *gpio_privacy; + } gpio; };u8 bNrInPins;
Signature · 1 line
2.29.2.299.gdc1121823c-goog
PATCH v3 6/8 media: uvcvideo: Add Privacy control based on EXT_GPIO
In reply to Ricardo RibaldaAdd a new control and mapping for Privacy controls connected to UVC_GUID_EXT_GPIO_CONTROLLERs.
--- drivers/media/usb/uvc/uvc_ctrl.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/media/usb/uvc/uvc_ctrl.c +18 -0
@@ -347,6 +347,14 @@ 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, + }, };static const struct uvc_menu_info power_line_frequency_controls[] = {
@@ -735,6 +743,16 @@ 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, + .name = "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, + }, };/* ------------------------------------------------------------------------
Signature · 1 line
2.29.2.299.gdc1121823c-goog
PATCH v3 7/8 media: uvcvideo: Use dev_ printk aliases
In reply to Ricardo RibaldaReplace all the uses of printk() and uvc_printk() with its equivalent dev_ alias macros.
They are more standard across the kernel tree and provide more context about the error.
--- drivers/media/usb/uvc/uvc_ctrl.c | 4 +- drivers/media/usb/uvc/uvc_driver.c | 80 ++++++++++++++++-------------- drivers/media/usb/uvc/uvc_entity.c | 10 ++-- drivers/media/usb/uvc/uvc_status.c | 13 ++--- drivers/media/usb/uvc/uvc_video.c | 51 ++++++++++--------- drivers/media/usb/uvc/uvcvideo.h | 25 ++++------ 6 files changed, 95 insertions(+), 88 deletions(-)
drivers/media/usb/uvc/uvc_ctrl.c +2 -2
@@ -1327,8 +1327,8 @@ static void uvc_ctrl_status_event_work(struct work_struct *work) w->urb->interval = dev->int_ep->desc.bInterval; ret =usb_submit_urb (w->urb,GFP_KERNEL );if (ret <0 ) -uvc_printk (KERN_ERR ,"Failed to resubmit status URB (%d).\n" , - ret); +dev_err (&dev->udev->dev, +"Failed to resubmit status URB (%d).\n" , ret); } bool uvc_ctrl_status_event(struct urb *urb, struct uvc_video_chain *chain,
drivers/media/usb/uvc/uvc_driver.c +42 -38
206 lines not on this page · raw message
drivers/media/usb/uvc/uvc_entity.c +6 -4
@@ -139,8 +139,9 @@ int uvc_mc_register_entities(struct uvc_video_chain *chain)list_for_each_entry (entity, &chain->entities, chain) { ret =uvc_mc_init_entity (chain, entity);if (ret <0 ) { -uvc_printk (KERN_INFO ,"Failed to initialize entity for " -"entity %u\n" , entity->id); +dev_info (&chain->dev->udev->dev, +"Failed to initialize entity for entity %u\n" , + entity->id);return ret; } }
@@ -148,8 +149,9 @@ int uvc_mc_register_entities(struct uvc_video_chain *chain)list_for_each_entry (entity, &chain->entities, chain) { ret =uvc_mc_create_links (chain, entity);if (ret <0 ) { -uvc_printk (KERN_INFO ,"Failed to create links for " -"entity %u\n" , entity->id); +dev_info (&chain->dev->udev->dev, +"Failed to create links for entity %u\n" , + entity->id);return ret; } }
drivers/media/usb/uvc/uvc_status.c +7 -6
@@ -208,8 +208,9 @@ static void uvc_status_complete(struct urb *urb)return ;default : -uvc_printk (KERN_WARNING ,"Non-zero status (%d) in status " -"completion handler.\n" , urb->status); +dev_warn (&dev->udev->dev, +"Non-zero status (%d) in status completion handler.\n" , + urb->status);return ; }
@@ -243,10 +244,10 @@ static void uvc_status_complete(struct urb *urb)/* Resubmit the URB. */ urb->interval = dev->int_ep->desc.bInterval; -if ((ret =usb_submit_urb (urb,GFP_ATOMIC )) <0 ) { -uvc_printk (KERN_ERR ,"Failed to resubmit status URB (%d).\n" , - ret); - } + ret =usb_submit_urb (urb,GFP_ATOMIC ); +if (ret <0 ) +dev_err (&dev->udev->dev, +"Failed to resubmit status URB (%d).\n" , ret); }int uvc_status_init (struct uvc_device *dev)
drivers/media/usb/uvc/uvc_video.c +27 -24
111 lines not on this page · raw message
drivers/media/usb/uvc/uvcvideo.h +11 -14
@@ -742,20 +742,17 @@ extern unsigned int uvc_trace_param;extern unsigned int uvc_timeout_param;extern unsigned int uvc_hw_timestamps_param; -#define uvc_trace(flag, msg...) \ - do { \ - if (uvc_trace_param & flag) \ - printk(KERN_DEBUG "uvcvideo: " msg); \ - } while (0) - -#define uvc_warn_once(dev, warn, msg...) \ - do { \ - if (!test_and_set_bit(warn, &dev->warnings)) \ - printk(KERN_INFO "uvcvideo: " msg); \ - } while (0) - -#define uvc_printk(level, msg...) \ - printk(level "uvcvideo: " msg) +#define uvc_trace (flag, fmt, ...) \ +do { \ + if (uvc_trace_param & flag) \ + printk(KERN_DEBUG "uvcvideo: " fmt, ##__VA_ARGS__); \ +} while (0) + +#define uvc_warn_once (_dev, warn, fmt, ...) \ +do { \ + if (!test_and_set_bit(warn, &(_dev)->warnings)) \ + dev_info(&(_dev)->udev->dev, fmt, ##__VA_ARGS__); \ +} while (0)/* -------------------------------------------------------------------------- * Internal functions.
Signature · 1 line
2.29.2.299.gdc1121823c-goog
PATCH v3 8/8 media: uvcvideo: New macro uvc_trace_cont
In reply to Ricardo RibaldaRemove all the duplicated code around pr_cont with a new macro.
--- drivers/media/usb/uvc/uvc_driver.c | 57 +++++++++++------------------- drivers/media/usb/uvc/uvcvideo.h | 6 ++++ 2 files changed, 27 insertions(+), 36 deletions(-)
drivers/media/usb/uvc/uvc_driver.c +21 -36
@@ -1593,8 +1593,7 @@ static int uvc_scan_chain_entity(struct uvc_video_chain *chain, {switch (UVC_ENTITY_TYPE (entity)) {case UVC_VC_EXTENSION_UNIT : -if (uvc_trace_param &UVC_TRACE_PROBE ) -pr_cont (" <- XU %d" , entity->id); +uvc_trace_cont (UVC_TRACE_PROBE ," <- XU %d" , entity->id);if (entity->bNrInPins !=1 ) { uvc_trace(UVC_TRACE_DESCR, "Extension unit %d has more "
@@ -1605,8 +1604,7 @@ static int uvc_scan_chain_entity(struct uvc_video_chain *chain,break ;case UVC_VC_PROCESSING_UNIT : -if (uvc_trace_param &UVC_TRACE_PROBE ) -pr_cont (" <- PU %d" , entity->id); +uvc_trace_cont (UVC_TRACE_PROBE ," <- PU %d" , entity->id);if (chain->processing !=NULL ) { uvc_trace(UVC_TRACE_DESCR, "Found multiple "
@@ -1618,8 +1616,7 @@ static int uvc_scan_chain_entity(struct uvc_video_chain *chain,break ;case UVC_VC_SELECTOR_UNIT : -if (uvc_trace_param &UVC_TRACE_PROBE ) -pr_cont (" <- SU %d" , entity->id); +uvc_trace_cont (UVC_TRACE_PROBE ," <- SU %d" , entity->id);/* Single-input selector units are ignored. */ if (entity->bNrInPins ==1 )
@@ -1637,27 +1634,22 @@ static int uvc_scan_chain_entity(struct uvc_video_chain *chain,case UVC_ITT_VENDOR_SPECIFIC :case UVC_ITT_CAMERA :case UVC_ITT_MEDIA_TRANSPORT_INPUT : -if (uvc_trace_param &UVC_TRACE_PROBE ) -pr_cont (" <- IT %d\n" , entity->id); +uvc_trace_cont (UVC_TRACE_PROBE ," <- IT %d\n" , entity->id);break ;case UVC_OTT_VENDOR_SPECIFIC :case UVC_OTT_DISPLAY :case UVC_OTT_MEDIA_TRANSPORT_OUTPUT : -if (uvc_trace_param &UVC_TRACE_PROBE ) -pr_cont (" OT %d" , entity->id); +uvc_trace_cont (UVC_TRACE_PROBE ," OT %d" , entity->id);break ;case UVC_TT_STREAMING : -if (UVC_ENTITY_IS_ITERM (entity)) { -if (uvc_trace_param &UVC_TRACE_PROBE ) -pr_cont (" <- IT %d\n" , entity->id); - }else { -if (uvc_trace_param &UVC_TRACE_PROBE ) -pr_cont (" OT %d" , entity->id); - } +if (UVC_ENTITY_IS_ITERM (entity)) +uvc_trace_cont (UVC_TRACE_PROBE ," <- IT %d\n" , entity->id); +else +uvc_trace_cont (UVC_TRACE_PROBE ," OT %d" , entity->id);break ;
@@ -1704,13 +1696,11 @@ static int uvc_scan_chain_forward(struct uvc_video_chain *chain, }list_add_tail (&forward->chain, &chain->entities); -if (uvc_trace_param &UVC_TRACE_PROBE ) { -if (!found) -pr_cont (" (->" ); +if (!found) +uvc_trace_cont (UVC_TRACE_PROBE ," (->" ); -pr_cont (" XU %d" , forward->id); - found =1 ; - } +uvc_trace_cont (UVC_TRACE_PROBE ," XU %d" , forward->id); + found =1 ;break ;case UVC_OTT_VENDOR_SPECIFIC :
@@ -1724,18 +1714,16 @@ static int uvc_scan_chain_forward(struct uvc_video_chain *chain, }list_add_tail (&forward->chain, &chain->entities); -if (uvc_trace_param &UVC_TRACE_PROBE ) { -if (!found) -pr_cont (" (->" ); +if (!found) +uvc_trace_cont (UVC_TRACE_PROBE ," (->" ); -pr_cont (" OT %d" , forward->id); - found =1 ; - } +uvc_trace_cont (UVC_TRACE_PROBE ," OT %d" , forward->id); + found =1 ;break ; } }if (found) -pr_cont (")" ); +uvc_trace_cont (UVC_TRACE_PROBE ,")" );return 0 ; }
@@ -1760,8 +1748,7 @@ static int uvc_scan_chain_backward(struct uvc_video_chain *chain,break ; } -if (uvc_trace_param &UVC_TRACE_PROBE ) -pr_cont (" <- IT" ); +uvc_trace_cont (UVC_TRACE_PROBE ," <- IT" ); chain->selector = entity;for (i =0 ; i < entity->bNrInPins; ++i) {
@@ -1781,15 +1768,13 @@ static int uvc_scan_chain_backward(struct uvc_video_chain *chain,return -EINVAL ; } -if (uvc_trace_param &UVC_TRACE_PROBE ) -pr_cont (" %d" , term->id); +uvc_trace_cont (UVC_TRACE_PROBE ," %d" , term->id);list_add_tail (&term->chain, &chain->entities);uvc_scan_chain_forward (chain, term, entity); } -if (uvc_trace_param &UVC_TRACE_PROBE ) -pr_cont ("\n" ); +uvc_trace_cont (UVC_TRACE_PROBE ,"\n" ); id =0 ;break ;
drivers/media/usb/uvc/uvcvideo.h +6 -0
@@ -748,6 +748,12 @@ do { \ printk(KERN_DEBUG "uvcvideo: " fmt, ##__VA_ARGS__); \ } while (0) +#define uvc_trace_cont (flag, fmt, ...) \ +do { \ + if (uvc_trace_param & flag) \ + pr_cont(fmt, ##__VA_ARGS__); \ +} while (0) +#define uvc_warn_once (_dev, warn, fmt, ...) \ do { \ if (!test_and_set_bit(warn, &(_dev)->warnings)) \
Signature · 1 line
2.29.2.299.gdc1121823c-goog