mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Ricardo Ribalda <ribalda@chromium.org>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
	linux-media@vger.kernel.org, Yunke Cao <yunkec@chromium.org>,
	linux-kernel@vger.kernel.org,
	Sergey Senozhatsky <senozhatsky@chromium.org>
Subject: Re: [PATCH v2 5/7] media: uvcvideo: Refactor power_line_frequency_controls_limited
Date: Fri, 6 Jan 2023 22:56:31 +0200	[thread overview]
Message-ID: <Y7iK/xuiSOsqBzqq@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20230105-uvc-gcc5-v2-5-2ba6c660d6f5@chromium.org>

Hi Ricardo,

Thank you for the patch.

On Thu, Jan 05, 2023 at 02:52:56PM +0100, Ricardo Ribalda wrote:
> Move the control mapping to uvc_ctrl.c. This way we do not have
> references to UVC controls or V4L2 controls in uvc_driver.c
> 
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
>  drivers/media/usb/uvc/uvc_ctrl.c   | 13 +++++++++++++
>  drivers/media/usb/uvc/uvc_driver.c | 18 ------------------
>  drivers/media/usb/uvc/uvcvideo.h   |  1 +
>  3 files changed, 14 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
> index 9af64f7a23d3..f559a1ac6e3c 100644
> --- a/drivers/media/usb/uvc/uvc_ctrl.c
> +++ b/drivers/media/usb/uvc/uvc_ctrl.c
> @@ -723,6 +723,19 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = {
>  	},
>  };
>  
> +const struct uvc_control_mapping uvc_ctrl_power_line_mapping_limited = {
> +	.id		= V4L2_CID_POWER_LINE_FREQUENCY,
> +	.entity		= UVC_GUID_UVC_PROCESSING,
> +	.selector	= UVC_PU_POWER_LINE_FREQUENCY_CONTROL,
> +	.size		= 2,
> +	.offset		= 0,
> +	.v4l2_type	= V4L2_CTRL_TYPE_MENU,
> +	.data_type	= UVC_CTRL_DATA_TYPE_ENUM,
> +	.menu_info	= power_line_frequency_controls,
> +	.menu_mask	= GENMASK(V4L2_CID_POWER_LINE_FREQUENCY_60HZ,
> +				  V4L2_CID_POWER_LINE_FREQUENCY_50HZ),

This also fixes a bug introduced in commit 382075604a68 ("media:
uvcvideo: Limit power line control for Quanta UVC Webcam"). The
offending commit caused the power line control menu entries to have
incorrect indices compared to the V4L2_CID_POWER_LINE_FREQUENCY_*
enumeration. Now that the limited mapping reuses the correct menu_info
array, the indices correctly map to the V4L2 control specification.

I'll add the above paragraph to the commit message, along with a Fixes:
line.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> +};
> +
>  static const struct uvc_control_mapping uvc_ctrl_power_line_mapping_uvc11 = {
>  	.id		= V4L2_CID_POWER_LINE_FREQUENCY,
>  	.entity		= UVC_GUID_UVC_PROCESSING,
> diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
> index e659670ea2d8..37d2b08bc8b2 100644
> --- a/drivers/media/usb/uvc/uvc_driver.c
> +++ b/drivers/media/usb/uvc/uvc_driver.c
> @@ -2378,24 +2378,6 @@ MODULE_PARM_DESC(timeout, "Streaming control requests timeout");
>   * Driver initialization and cleanup
>   */
>  
> -static const struct uvc_menu_info power_line_frequency_controls_limited[] = {
> -	{ 1, "50 Hz" },
> -	{ 2, "60 Hz" },
> -};
> -
> -static const struct uvc_control_mapping uvc_ctrl_power_line_mapping_limited = {
> -	.id		= V4L2_CID_POWER_LINE_FREQUENCY,
> -	.entity		= UVC_GUID_UVC_PROCESSING,
> -	.selector	= UVC_PU_POWER_LINE_FREQUENCY_CONTROL,
> -	.size		= 2,
> -	.offset		= 0,
> -	.v4l2_type	= V4L2_CTRL_TYPE_MENU,
> -	.data_type	= UVC_CTRL_DATA_TYPE_ENUM,
> -	.menu_info	= power_line_frequency_controls_limited,
> -	.menu_mask	=
> -		GENMASK(ARRAY_SIZE(power_line_frequency_controls_limited) - 1, 0),
> -};
> -
>  static const struct uvc_device_info uvc_ctrl_power_line_limited = {
>  	.mappings = (const struct uvc_control_mapping *[]) {
>  		&uvc_ctrl_power_line_mapping_limited,
> diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
> index a8eec43cd860..1b2d9f327583 100644
> --- a/drivers/media/usb/uvc/uvcvideo.h
> +++ b/drivers/media/usb/uvc/uvcvideo.h
> @@ -747,6 +747,7 @@ int uvc_status_start(struct uvc_device *dev, gfp_t flags);
>  void uvc_status_stop(struct uvc_device *dev);
>  
>  /* Controls */
> +extern const struct uvc_control_mapping uvc_ctrl_power_line_mapping_limited;
>  extern const struct v4l2_subscribed_event_ops uvc_ctrl_sub_ev_ops;
>  
>  int uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
> 

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2023-01-06 20:56 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-05 13:52 [PATCH v2 0/7] media: uvcvideo: Hot fixes for top of next/uvc + std menus Ricardo Ribalda
2023-01-05 13:52 ` [PATCH v2 1/7] Revert "media: uvcvideo: Fix power line control for Lenovo Integrated Camera" Ricardo Ribalda
2023-01-05 13:52 ` [PATCH v2 2/7] Revert "media: uvcvideo: Implement mask for V4L2_CTRL_TYPE_MENU" Ricardo Ribalda
2023-01-05 13:52 ` [PATCH v2 3/7] media: uvcvideo: Implement mask for V4L2_CTRL_TYPE_MENU Ricardo Ribalda
2023-01-06 20:22   ` Laurent Pinchart
2023-01-05 13:52 ` [PATCH v2 4/7] media: uvcvideo: Refactor uvc_ctrl_mappings_uvcXX Ricardo Ribalda
2023-01-06 20:45   ` Laurent Pinchart
2023-01-05 13:52 ` [PATCH v2 5/7] media: uvcvideo: Refactor power_line_frequency_controls_limited Ricardo Ribalda
2023-01-06 20:56   ` Laurent Pinchart [this message]
2023-01-05 13:52 ` [PATCH v2 6/7] media: uvcvideo: Fix power line control for Lenovo Integrated Camera Ricardo Ribalda
2023-01-06 20:59   ` Laurent Pinchart
2023-01-05 13:52 ` [PATCH v2 7/7] media: uvcvideo: Use standard names for menus Ricardo Ribalda
2023-01-06 21:31   ` Laurent Pinchart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y7iK/xuiSOsqBzqq@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=ribalda@chromium.org \
    --cc=senozhatsky@chromium.org \
    --cc=yunkec@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®