mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/bridge: sii902x: Fix mode_valid hook
@ 2024-04-08  8:14 Jayesh Choudhary
  2024-04-15  7:40 ` Maxime Ripard
  0 siblings, 1 reply; 3+ messages in thread
From: Jayesh Choudhary @ 2024-04-08  8:14 UTC (permalink / raw)
  To: andrzej.hajda, neil.armstrong, rfoss, Laurent.pinchart, mripard,
	j-choudhary
  Cc: jonas, jernej.skrabec, maarten.lankhorst, tzimmermann, airlied,
	daniel, dri-devel, linux-kernel

Currently, mode_valid hook returns all mode as valid. Add the check
for the maximum and minimum pixel clock that the bridge can support
while validating a mode.

Signed-off-by: Jayesh Choudhary <j-choudhary@ti.com>
---
 drivers/gpu/drm/bridge/sii902x.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c
index 8f84e98249c7..658819199c84 100644
--- a/drivers/gpu/drm/bridge/sii902x.c
+++ b/drivers/gpu/drm/bridge/sii902x.c
@@ -163,6 +163,16 @@
 
 #define SII902X_AUDIO_PORT_INDEX		3
 
+/*
+ * The maximum resolution supported by the HDMI bridge is 1080p@60Hz
+ * and 1920x1200 requiring a pixel clock of 165MHz and the minimum
+ * resolution supported is 480p@60Hz requiring a pixel clock of 25MHz
+ *
+ * (drm_display_mode clock is in kHz)
+ */
+#define SII902X_MIN_PIXEL_CLOCK			25000
+#define SII902X_MAX_PIXEL_CLOCK			165000
+
 struct sii902x {
 	struct i2c_client *i2c;
 	struct regmap *regmap;
@@ -313,7 +323,11 @@ static int sii902x_get_modes(struct drm_connector *connector)
 static enum drm_mode_status sii902x_mode_valid(struct drm_connector *connector,
 					       struct drm_display_mode *mode)
 {
-	/* TODO: check mode */
+	if (mode->clock < SII902X_MIN_PIXEL_CLOCK)
+		return MODE_CLOCK_LOW;
+
+	if (mode->clock > SII902X_MAX_PIXEL_CLOCK)
+		return MODE_CLOCK_HIGH;
 
 	return MODE_OK;
 }
-- 
2.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/bridge: sii902x: Fix mode_valid hook
  2024-04-08  8:14 [PATCH] drm/bridge: sii902x: Fix mode_valid hook Jayesh Choudhary
@ 2024-04-15  7:40 ` Maxime Ripard
  2024-05-03 15:13   ` Jayesh Choudhary
  0 siblings, 1 reply; 3+ messages in thread
From: Maxime Ripard @ 2024-04-15  7:40 UTC (permalink / raw)
  To: Jayesh Choudhary
  Cc: andrzej.hajda, neil.armstrong, rfoss, Laurent.pinchart, jonas,
	jernej.skrabec, maarten.lankhorst, tzimmermann, airlied, daniel,
	dri-devel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1789 bytes --]

Hi,

On Mon, Apr 08, 2024 at 01:44:35PM +0530, Jayesh Choudhary wrote:
> Currently, mode_valid hook returns all mode as valid. Add the check
> for the maximum and minimum pixel clock that the bridge can support
> while validating a mode.
> 
> Signed-off-by: Jayesh Choudhary <j-choudhary@ti.com>
> ---
>  drivers/gpu/drm/bridge/sii902x.c | 16 +++++++++++++++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c
> index 8f84e98249c7..658819199c84 100644
> --- a/drivers/gpu/drm/bridge/sii902x.c
> +++ b/drivers/gpu/drm/bridge/sii902x.c
> @@ -163,6 +163,16 @@
>  
>  #define SII902X_AUDIO_PORT_INDEX		3
>  
> +/*
> + * The maximum resolution supported by the HDMI bridge is 1080p@60Hz
> + * and 1920x1200 requiring a pixel clock of 165MHz and the minimum
> + * resolution supported is 480p@60Hz requiring a pixel clock of 25MHz
> + *
> + * (drm_display_mode clock is in kHz)
> + */
> +#define SII902X_MIN_PIXEL_CLOCK			25000
> +#define SII902X_MAX_PIXEL_CLOCK			165000
> +

You should probably add a KHZ suffix or something to make it obvious.
The natural unit for a frequency is Hertz.

>  struct sii902x {
>  	struct i2c_client *i2c;
>  	struct regmap *regmap;
> @@ -313,7 +323,11 @@ static int sii902x_get_modes(struct drm_connector *connector)
>  static enum drm_mode_status sii902x_mode_valid(struct drm_connector *connector,
>  					       struct drm_display_mode *mode)
>  {
> -	/* TODO: check mode */
> +	if (mode->clock < SII902X_MIN_PIXEL_CLOCK)
> +		return MODE_CLOCK_LOW;
> +
> +	if (mode->clock > SII902X_MAX_PIXEL_CLOCK)
> +		return MODE_CLOCK_HIGH;
>  
>  	return MODE_OK;
>  }

It's something you should do in atomic_check too

Maxime

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 273 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/bridge: sii902x: Fix mode_valid hook
  2024-04-15  7:40 ` Maxime Ripard
@ 2024-05-03 15:13   ` Jayesh Choudhary
  0 siblings, 0 replies; 3+ messages in thread
From: Jayesh Choudhary @ 2024-05-03 15:13 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: andrzej.hajda, neil.armstrong, rfoss, Laurent.pinchart, jonas,
	jernej.skrabec, maarten.lankhorst, tzimmermann, airlied, daniel,
	dri-devel, linux-kernel

Hello Maxime,

Thanks for the review.

On 15/04/24 13:10, Maxime Ripard wrote:
> Hi,
> 
> On Mon, Apr 08, 2024 at 01:44:35PM +0530, Jayesh Choudhary wrote:
>> Currently, mode_valid hook returns all mode as valid. Add the check
>> for the maximum and minimum pixel clock that the bridge can support
>> while validating a mode.
>>
>> Signed-off-by: Jayesh Choudhary <j-choudhary@ti.com>
>> ---
>>   drivers/gpu/drm/bridge/sii902x.c | 16 +++++++++++++++-
>>   1 file changed, 15 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c
>> index 8f84e98249c7..658819199c84 100644
>> --- a/drivers/gpu/drm/bridge/sii902x.c
>> +++ b/drivers/gpu/drm/bridge/sii902x.c
>> @@ -163,6 +163,16 @@
>>   
>>   #define SII902X_AUDIO_PORT_INDEX		3
>>   
>> +/*
>> + * The maximum resolution supported by the HDMI bridge is 1080p@60Hz
>> + * and 1920x1200 requiring a pixel clock of 165MHz and the minimum
>> + * resolution supported is 480p@60Hz requiring a pixel clock of 25MHz
>> + *
>> + * (drm_display_mode clock is in kHz)
>> + */
>> +#define SII902X_MIN_PIXEL_CLOCK			25000
>> +#define SII902X_MAX_PIXEL_CLOCK			165000
>> +
> 
> You should probably add a KHZ suffix or something to make it obvious.
> The natural unit for a frequency is Hertz.

Okay.
Instead of adding the kHz in comments, I will add that in suffix
like SII902X_MIN_PIXEL_CLOCK_KHZ.

> 
>>   struct sii902x {
>>   	struct i2c_client *i2c;
>>   	struct regmap *regmap;
>> @@ -313,7 +323,11 @@ static int sii902x_get_modes(struct drm_connector *connector)
>>   static enum drm_mode_status sii902x_mode_valid(struct drm_connector *connector,
>>   					       struct drm_display_mode *mode)
>>   {
>> -	/* TODO: check mode */
>> +	if (mode->clock < SII902X_MIN_PIXEL_CLOCK)
>> +		return MODE_CLOCK_LOW;
>> +
>> +	if (mode->clock > SII902X_MAX_PIXEL_CLOCK)
>> +		return MODE_CLOCK_HIGH;
>>   
>>   	return MODE_OK;
>>   }
> 
> It's something you should do in atomic_check too
> 

Like using clock from adjusted mode in crtc_state?
Will update in the next revision.

Warm Regards,
-Jayesh

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-05-03 15:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-08  8:14 [PATCH] drm/bridge: sii902x: Fix mode_valid hook Jayesh Choudhary
2024-04-15  7:40 ` Maxime Ripard
2024-05-03 15:13   ` Jayesh Choudhary

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®