diff mbox series

[v4,24/25] media:i2c: imx258: Use v4l2_link_freq_to_bitmap helper

Message ID 20240414203503.18402-25-git@luigi311.com (mailing list archive)
State Superseded
Headers show
Series imx258 improvement series | expand

Commit Message

Luis Garcia April 14, 2024, 8:35 p.m. UTC
From: Luis Garcia <git@luigi311.com>

Use the v4l2_link_freq_to_bitmap() helper to figure out which
driver-supported link freq can be used on a given system.

Signed-off-by: Luis Garcia <git@luigi311.com>
Reviewed-by: Pavel Machek <pavel@ucw.cz>
---
 drivers/media/i2c/imx258.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Tommaso Merciai April 15, 2024, 3:18 p.m. UTC | #1
Hi Luis,

On Sun, Apr 14, 2024 at 02:35:02PM -0600, git@luigi311.com wrote:
> From: Luis Garcia <git@luigi311.com>
> 
> Use the v4l2_link_freq_to_bitmap() helper to figure out which
> driver-supported link freq can be used on a given system.
> 
> Signed-off-by: Luis Garcia <git@luigi311.com>
> Reviewed-by: Pavel Machek <pavel@ucw.cz>
> ---
>  drivers/media/i2c/imx258.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/media/i2c/imx258.c b/drivers/media/i2c/imx258.c
> index 5de71cb7c1ae..65846dff775e 100644
> --- a/drivers/media/i2c/imx258.c
> +++ b/drivers/media/i2c/imx258.c
> @@ -693,6 +693,7 @@ struct imx258 {
>  	/* Current mode */
>  	const struct imx258_mode *cur_mode;
>  
> +	unsigned long link_freq_bitmap;
>  	const struct imx258_link_freq_config *link_freq_configs;
>  	const s64 *link_freq_menu_items;
>  	unsigned int lane_mode_idx;
> @@ -1552,6 +1553,17 @@ static int imx258_probe(struct i2c_client *client)
>  		return ret;
>  	}
>  
> +	ret = v4l2_link_freq_to_bitmap(&client->dev,
> +				       ep.link_frequencies,
> +				       ep.nr_of_link_frequencies,
> +				       imx258->link_freq_menu_items,
> +				       ARRAY_SIZE(link_freq_menu_items_19_2),
> +				       &imx258->link_freq_bitmap);
> +	if (ret) {
> +		dev_err(&client->dev, "Link frequency not supported\n");
> +		goto error_endpoint_free;
> +	}
> +
>  	/* Get number of data lanes */
>  	switch (ep.bus.mipi_csi2.num_data_lanes) {
>  	case 2:

Looks good to me.

ps:
Maybe a good plan for the future would be to use: dev_err_probe
(instead of dev_err into probe function)

But this I think is somenthing for next improvements. :)

Thanks & Regards,
Tommaso

> -- 
> 2.44.0
> 
>
Luis Garcia April 15, 2024, 4:27 p.m. UTC | #2
On 4/15/24 09:18, Tommaso Merciai wrote:
> Hi Luis,
> 
> On Sun, Apr 14, 2024 at 02:35:02PM -0600, git@luigi311.com wrote:
>> From: Luis Garcia <git@luigi311.com>
>>
>> Use the v4l2_link_freq_to_bitmap() helper to figure out which
>> driver-supported link freq can be used on a given system.
>>
>> Signed-off-by: Luis Garcia <git@luigi311.com>
>> Reviewed-by: Pavel Machek <pavel@ucw.cz>
>> ---
>>  drivers/media/i2c/imx258.c | 12 ++++++++++++
>>  1 file changed, 12 insertions(+)
>>
>> diff --git a/drivers/media/i2c/imx258.c b/drivers/media/i2c/imx258.c
>> index 5de71cb7c1ae..65846dff775e 100644
>> --- a/drivers/media/i2c/imx258.c
>> +++ b/drivers/media/i2c/imx258.c
>> @@ -693,6 +693,7 @@ struct imx258 {
>>  	/* Current mode */
>>  	const struct imx258_mode *cur_mode;
>>  
>> +	unsigned long link_freq_bitmap;
>>  	const struct imx258_link_freq_config *link_freq_configs;
>>  	const s64 *link_freq_menu_items;
>>  	unsigned int lane_mode_idx;
>> @@ -1552,6 +1553,17 @@ static int imx258_probe(struct i2c_client *client)
>>  		return ret;
>>  	}
>>  
>> +	ret = v4l2_link_freq_to_bitmap(&client->dev,
>> +				       ep.link_frequencies,
>> +				       ep.nr_of_link_frequencies,
>> +				       imx258->link_freq_menu_items,
>> +				       ARRAY_SIZE(link_freq_menu_items_19_2),
>> +				       &imx258->link_freq_bitmap);
>> +	if (ret) {
>> +		dev_err(&client->dev, "Link frequency not supported\n");
>> +		goto error_endpoint_free;
>> +	}
>> +
>>  	/* Get number of data lanes */
>>  	switch (ep.bus.mipi_csi2.num_data_lanes) {
>>  	case 2:
> 
> Looks good to me.
> 
> ps:
> Maybe a good plan for the future would be to use: dev_err_probe
> (instead of dev_err into probe function)
> 
> But this I think is somenthing for next improvements. :)
> 
> Thanks & Regards,
> Tommaso
> 

Perfect, can i go ahead and add in your reviewed by looks like
you didnt add it here.

>> -- 
>> 2.44.0
>>
>>
Tommaso Merciai April 15, 2024, 4:32 p.m. UTC | #3
On Mon, Apr 15, 2024 at 10:27:28AM -0600, Luis Garcia wrote:
> On 4/15/24 09:18, Tommaso Merciai wrote:
> > Hi Luis,
> > 
> > On Sun, Apr 14, 2024 at 02:35:02PM -0600, git@luigi311.com wrote:
> >> From: Luis Garcia <git@luigi311.com>
> >>
> >> Use the v4l2_link_freq_to_bitmap() helper to figure out which
> >> driver-supported link freq can be used on a given system.
> >>
> >> Signed-off-by: Luis Garcia <git@luigi311.com>
> >> Reviewed-by: Pavel Machek <pavel@ucw.cz>
> >> ---
> >>  drivers/media/i2c/imx258.c | 12 ++++++++++++
> >>  1 file changed, 12 insertions(+)
> >>
> >> diff --git a/drivers/media/i2c/imx258.c b/drivers/media/i2c/imx258.c
> >> index 5de71cb7c1ae..65846dff775e 100644
> >> --- a/drivers/media/i2c/imx258.c
> >> +++ b/drivers/media/i2c/imx258.c
> >> @@ -693,6 +693,7 @@ struct imx258 {
> >>  	/* Current mode */
> >>  	const struct imx258_mode *cur_mode;
> >>  
> >> +	unsigned long link_freq_bitmap;
> >>  	const struct imx258_link_freq_config *link_freq_configs;
> >>  	const s64 *link_freq_menu_items;
> >>  	unsigned int lane_mode_idx;
> >> @@ -1552,6 +1553,17 @@ static int imx258_probe(struct i2c_client *client)
> >>  		return ret;
> >>  	}
> >>  
> >> +	ret = v4l2_link_freq_to_bitmap(&client->dev,
> >> +				       ep.link_frequencies,
> >> +				       ep.nr_of_link_frequencies,
> >> +				       imx258->link_freq_menu_items,
> >> +				       ARRAY_SIZE(link_freq_menu_items_19_2),
> >> +				       &imx258->link_freq_bitmap);
> >> +	if (ret) {
> >> +		dev_err(&client->dev, "Link frequency not supported\n");
> >> +		goto error_endpoint_free;
> >> +	}
> >> +
> >>  	/* Get number of data lanes */
> >>  	switch (ep.bus.mipi_csi2.num_data_lanes) {
> >>  	case 2:
> > 
> > Looks good to me.
> > 
> > ps:
> > Maybe a good plan for the future would be to use: dev_err_probe
> > (instead of dev_err into probe function)
> > 
> > But this I think is somenthing for next improvements. :)
> > 
> > Thanks & Regards,
> > Tommaso
> > 
> 
> Perfect, can i go ahead and add in your reviewed by looks like
> you didnt add it here.

Yep sorry I miss that. :'(

Thanks & Regards,
Tommaso

> 
> >> -- 
> >> 2.44.0
> >>
> >>
>
diff mbox series

Patch

diff --git a/drivers/media/i2c/imx258.c b/drivers/media/i2c/imx258.c
index 5de71cb7c1ae..65846dff775e 100644
--- a/drivers/media/i2c/imx258.c
+++ b/drivers/media/i2c/imx258.c
@@ -693,6 +693,7 @@  struct imx258 {
 	/* Current mode */
 	const struct imx258_mode *cur_mode;
 
+	unsigned long link_freq_bitmap;
 	const struct imx258_link_freq_config *link_freq_configs;
 	const s64 *link_freq_menu_items;
 	unsigned int lane_mode_idx;
@@ -1552,6 +1553,17 @@  static int imx258_probe(struct i2c_client *client)
 		return ret;
 	}
 
+	ret = v4l2_link_freq_to_bitmap(&client->dev,
+				       ep.link_frequencies,
+				       ep.nr_of_link_frequencies,
+				       imx258->link_freq_menu_items,
+				       ARRAY_SIZE(link_freq_menu_items_19_2),
+				       &imx258->link_freq_bitmap);
+	if (ret) {
+		dev_err(&client->dev, "Link frequency not supported\n");
+		goto error_endpoint_free;
+	}
+
 	/* Get number of data lanes */
 	switch (ep.bus.mipi_csi2.num_data_lanes) {
 	case 2: