From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: Umang Jain <umang.jain@ideasonboard.com>
Cc: linux-media@vger.kernel.org,
Kieran Bingham <kieran.bingham@ideasonboard.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 2/5] media: imx335: Use v4l2_link_freq_to_bitmap helper
Date: Thu, 15 Feb 2024 12:51:19 +0000 [thread overview]
Message-ID: <Zc4Ix32Ld_bCD-LO@kekkonen.localdomain> (raw)
In-Reply-To: <20240131055208.170934-3-umang.jain@ideasonboard.com>
Hi Umang,
On Wed, Jan 31, 2024 at 11:22:05AM +0530, Umang Jain wrote:
> Use the v4l2_link_freq_to_bitmap() helper to figure out which
> driver-supported link frequencies can be used on a given system.
>
> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
> ---
> drivers/media/i2c/imx335.c | 36 ++++++++++++++++++------------------
> 1 file changed, 18 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/media/i2c/imx335.c b/drivers/media/i2c/imx335.c
> index 927b4806a5d7..73691069556f 100644
> --- a/drivers/media/i2c/imx335.c
> +++ b/drivers/media/i2c/imx335.c
> @@ -49,7 +49,7 @@
> #define IMX335_INCLK_RATE 24000000
>
> /* CSI2 HW configuration */
> -#define IMX335_LINK_FREQ 594000000
> +#define IMX335_LINK_FREQ 594000000LL
If you change this, please make it ULL---it's unsigned.
> #define IMX335_NUM_DATA_LANES 4
>
> #define IMX335_REG_MIN 0x00
> @@ -134,6 +134,7 @@ struct imx335_mode {
> * @vblank: Vertical blanking in lines
> * @cur_mode: Pointer to current selected sensor mode
> * @mutex: Mutex for serializing sensor controls
> + * @link_freq_bitmap: Menu bitmap for link_freq_ctrl
> * @cur_mbus_code: Currently selected media bus format code
> */
> struct imx335 {
> @@ -157,6 +158,7 @@ struct imx335 {
> u32 vblank;
> const struct imx335_mode *cur_mode;
> struct mutex mutex;
> + unsigned long link_freq_bitmap;
> u32 cur_mbus_code;
> };
>
> @@ -404,7 +406,8 @@ static int imx335_update_controls(struct imx335 *imx335,
> {
> int ret;
>
> - ret = __v4l2_ctrl_s_ctrl(imx335->link_freq_ctrl, mode->link_freq_idx);
> + ret = __v4l2_ctrl_s_ctrl(imx335->link_freq_ctrl,
> + __ffs(imx335->link_freq_bitmap));
> if (ret)
> return ret;
>
> @@ -690,6 +693,13 @@ static int imx335_init_state(struct v4l2_subdev *sd,
> fmt.which = sd_state ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE;
> imx335_fill_pad_format(imx335, &supported_mode, &fmt);
>
> + mutex_lock(&imx335->mutex);
> + __v4l2_ctrl_modify_range(imx335->link_freq_ctrl, 0,
> + __fls(imx335->link_freq_bitmap),
> + ~(imx335->link_freq_bitmap),
> + __ffs(imx335->link_freq_bitmap));
> + mutex_unlock(&imx335->mutex);
> +
> return imx335_set_pad_format(sd, sd_state, &fmt);
> }
>
> @@ -938,19 +948,10 @@ static int imx335_parse_hw_config(struct imx335 *imx335)
> goto done_endpoint_free;
> }
>
> - if (!bus_cfg.nr_of_link_frequencies) {
> - dev_err(imx335->dev, "no link frequencies defined\n");
> - ret = -EINVAL;
> - goto done_endpoint_free;
> - }
> -
> - for (i = 0; i < bus_cfg.nr_of_link_frequencies; i++)
> - if (bus_cfg.link_frequencies[i] == IMX335_LINK_FREQ)
> - goto done_endpoint_free;
> -
> - dev_err(imx335->dev, "no compatible link frequencies found\n");
> -
> - ret = -EINVAL;
> + ret = v4l2_link_freq_to_bitmap(imx335->dev, bus_cfg.link_frequencies,
> + bus_cfg.nr_of_link_frequencies,
> + link_freq, ARRAY_SIZE(link_freq),
> + &imx335->link_freq_bitmap);
Thanks! :-)
>
> done_endpoint_free:
> v4l2_fwnode_endpoint_free(&bus_cfg);
> @@ -1098,9 +1099,8 @@ static int imx335_init_controls(struct imx335 *imx335)
> imx335->link_freq_ctrl = v4l2_ctrl_new_int_menu(ctrl_hdlr,
> &imx335_ctrl_ops,
> V4L2_CID_LINK_FREQ,
> - ARRAY_SIZE(link_freq) -
> - 1,
> - mode->link_freq_idx,
> + __fls(imx335->link_freq_bitmap),
> + __ffs(imx335->link_freq_bitmap),
> link_freq);
> if (imx335->link_freq_ctrl)
> imx335->link_freq_ctrl->flags |= V4L2_CTRL_FLAG_READ_ONLY;
--
Regards,
Sakari Ailus
next prev parent reply other threads:[~2024-02-15 12:51 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-31 5:52 [PATCH v2 0/5] imx335: Support additional link-freq and TPG Umang Jain
2024-01-31 5:52 ` [PATCH v2 1/5] media: i2c: imx335: Drop setting of 0x3a00 register Umang Jain
2024-01-31 9:52 ` Kieran Bingham
2024-01-31 10:32 ` Matthias Fend
2024-02-07 4:21 ` Umang Jain
2024-02-15 12:50 ` Sakari Ailus
2024-01-31 5:52 ` [PATCH v2 2/5] media: imx335: Use v4l2_link_freq_to_bitmap helper Umang Jain
2024-02-15 12:51 ` Sakari Ailus [this message]
2024-02-15 12:53 ` Sakari Ailus
2024-01-31 5:52 ` [PATCH v2 3/5] media: i2c: imx335: Support multiple link frequency Umang Jain
2024-02-15 12:53 ` Sakari Ailus
2024-01-31 5:52 ` [PATCH v2 4/5] media: i2c: imx335: Refactor power sequence to set controls Umang Jain
2024-01-31 5:52 ` [PATCH v2 5/5] media: i2c: imx335: Add support for test pattern generator Umang Jain
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=Zc4Ix32Ld_bCD-LO@kekkonen.localdomain \
--to=sakari.ailus@linux.intel.com \
--cc=kieran.bingham@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=umang.jain@ideasonboard.com \
/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®