linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gpu/drm: mediatek: hdmi: check for valid modes on MT8167
@ 2021-04-09  8:43 Neil Armstrong
  2021-04-09 22:41 ` Chun-Kuang Hu
  0 siblings, 1 reply; 3+ messages in thread
From: Neil Armstrong @ 2021-04-09  8:43 UTC (permalink / raw)
  To: chunkuang.hu, p.zabel, matthias.bgg
  Cc: dri-devel, linux-mediatek, linux-arm-kernel, linux-kernel,
	Neil Armstrong, Fabien Parent

On MT8167, only CEA modes and anything using a clock below 148500 is
supported for HDMI. This change adds some checks to make sure the
video format is OK for MT8167.

Signed-off-by: Fabien Parent <fparent@baylibre.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
 drivers/gpu/drm/mediatek/mtk_hdmi.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c
index 8ee55f9e2954..991e2e935b93 100644
--- a/drivers/gpu/drm/mediatek/mtk_hdmi.c
+++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c
@@ -148,6 +148,8 @@ struct hdmi_audio_param {
 
 struct mtk_hdmi_conf {
 	bool tz_disabled;
+	unsigned long max_mode_clock;
+	bool cea_modes_only;
 };
 
 struct mtk_hdmi {
@@ -1259,6 +1261,13 @@ static int mtk_hdmi_conn_mode_valid(struct drm_connector *conn,
 			return MODE_BAD;
 	}
 
+	if (hdmi->conf->cea_modes_only && !drm_match_cea_mode(mode))
+		return MODE_BAD;
+
+	if (hdmi->conf->max_mode_clock &&
+	    mode->clock > hdmi->conf->max_mode_clock)
+		return MODE_CLOCK_HIGH;
+
 	if (mode->clock < 27000)
 		return MODE_CLOCK_LOW;
 	if (mode->clock > 297000)
@@ -1810,10 +1819,18 @@ static const struct mtk_hdmi_conf mtk_hdmi_conf_mt2701 = {
 	.tz_disabled = true,
 };
 
+static const struct mtk_hdmi_conf mtk_hdmi_conf_mt8167 = {
+	.max_mode_clock = 148500,
+	.cea_modes_only = true,
+};
+
 static const struct of_device_id mtk_drm_hdmi_of_ids[] = {
 	{ .compatible = "mediatek,mt2701-hdmi",
 	  .data = &mtk_hdmi_conf_mt2701,
 	},
+	{ .compatible = "mediatek,mt8167-hdmi",
+	  .data = &mtk_hdmi_conf_mt8167,
+	},
 	{ .compatible = "mediatek,mt8173-hdmi",
 	},
 	{}
-- 
2.25.1


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

* Re: [PATCH] gpu/drm: mediatek: hdmi: check for valid modes on MT8167
  2021-04-09  8:43 [PATCH] gpu/drm: mediatek: hdmi: check for valid modes on MT8167 Neil Armstrong
@ 2021-04-09 22:41 ` Chun-Kuang Hu
  2021-04-12  8:26   ` Neil Armstrong
  0 siblings, 1 reply; 3+ messages in thread
From: Chun-Kuang Hu @ 2021-04-09 22:41 UTC (permalink / raw)
  To: Neil Armstrong
  Cc: Chun-Kuang Hu, Philipp Zabel, Matthias Brugger, DRI Development,
	moderated list:ARM/Mediatek SoC support, Linux ARM, linux-kernel,
	Fabien Parent

Hi, Neil:

Neil Armstrong <narmstrong@baylibre.com> 於 2021年4月9日 週五 下午4:43寫道:
>
> On MT8167, only CEA modes and anything using a clock below 148500 is
> supported for HDMI. This change adds some checks to make sure the
> video format is OK for MT8167.

I think this patch should be separated to 3 patches. check CEA mode,
check clock, add mt8167 hdmi support.

>
> Signed-off-by: Fabien Parent <fparent@baylibre.com>
> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
> ---
>  drivers/gpu/drm/mediatek/mtk_hdmi.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c
> index 8ee55f9e2954..991e2e935b93 100644
> --- a/drivers/gpu/drm/mediatek/mtk_hdmi.c
> +++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c
> @@ -148,6 +148,8 @@ struct hdmi_audio_param {
>
>  struct mtk_hdmi_conf {
>         bool tz_disabled;
> +       unsigned long max_mode_clock;
> +       bool cea_modes_only;
>  };
>
>  struct mtk_hdmi {
> @@ -1259,6 +1261,13 @@ static int mtk_hdmi_conn_mode_valid(struct drm_connector *conn,
>                         return MODE_BAD;
>         }
>
> +       if (hdmi->conf->cea_modes_only && !drm_match_cea_mode(mode))
> +               return MODE_BAD;
> +
> +       if (hdmi->conf->max_mode_clock &&
> +           mode->clock > hdmi->conf->max_mode_clock)
> +               return MODE_CLOCK_HIGH;
> +
>         if (mode->clock < 27000)
>                 return MODE_CLOCK_LOW;
>         if (mode->clock > 297000)
> @@ -1810,10 +1819,18 @@ static const struct mtk_hdmi_conf mtk_hdmi_conf_mt2701 = {
>         .tz_disabled = true,
>  };
>
> +static const struct mtk_hdmi_conf mtk_hdmi_conf_mt8167 = {
> +       .max_mode_clock = 148500,
> +       .cea_modes_only = true,
> +};
> +
>  static const struct of_device_id mtk_drm_hdmi_of_ids[] = {
>         { .compatible = "mediatek,mt2701-hdmi",
>           .data = &mtk_hdmi_conf_mt2701,
>         },
> +       { .compatible = "mediatek,mt8167-hdmi",

"mediatek,mt8167-hdmi" does not exist in binding document, so add this
to binding document first.
In addition, could you also transfer mediatek,hdmi.txt to yaml format?

Regards,
Chun-Kuang.

> +         .data = &mtk_hdmi_conf_mt8167,
> +       },
>         { .compatible = "mediatek,mt8173-hdmi",
>         },
>         {}
> --
> 2.25.1
>

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

* Re: [PATCH] gpu/drm: mediatek: hdmi: check for valid modes on MT8167
  2021-04-09 22:41 ` Chun-Kuang Hu
@ 2021-04-12  8:26   ` Neil Armstrong
  0 siblings, 0 replies; 3+ messages in thread
From: Neil Armstrong @ 2021-04-12  8:26 UTC (permalink / raw)
  To: Chun-Kuang Hu
  Cc: Philipp Zabel, Matthias Brugger, DRI Development,
	moderated list:ARM/Mediatek SoC support, Linux ARM, linux-kernel,
	Fabien Parent

On 10/04/2021 00:41, Chun-Kuang Hu wrote:
> Hi, Neil:
> 
> Neil Armstrong <narmstrong@baylibre.com> 於 2021年4月9日 週五 下午4:43寫道:
>>
>> On MT8167, only CEA modes and anything using a clock below 148500 is
>> supported for HDMI. This change adds some checks to make sure the
>> video format is OK for MT8167.
> 
> I think this patch should be separated to 3 patches. check CEA mode,
> check clock, add mt8167 hdmi support.

Ok

> 
>>
>> Signed-off-by: Fabien Parent <fparent@baylibre.com>
>> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
>> ---
>>  drivers/gpu/drm/mediatek/mtk_hdmi.c | 17 +++++++++++++++++
>>  1 file changed, 17 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c
>> index 8ee55f9e2954..991e2e935b93 100644
>> --- a/drivers/gpu/drm/mediatek/mtk_hdmi.c
>> +++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c
>> @@ -148,6 +148,8 @@ struct hdmi_audio_param {
>>
>>  struct mtk_hdmi_conf {
>>         bool tz_disabled;
>> +       unsigned long max_mode_clock;
>> +       bool cea_modes_only;
>>  };
>>
>>  struct mtk_hdmi {
>> @@ -1259,6 +1261,13 @@ static int mtk_hdmi_conn_mode_valid(struct drm_connector *conn,
>>                         return MODE_BAD;
>>         }
>>
>> +       if (hdmi->conf->cea_modes_only && !drm_match_cea_mode(mode))
>> +               return MODE_BAD;
>> +
>> +       if (hdmi->conf->max_mode_clock &&
>> +           mode->clock > hdmi->conf->max_mode_clock)
>> +               return MODE_CLOCK_HIGH;
>> +
>>         if (mode->clock < 27000)
>>                 return MODE_CLOCK_LOW;
>>         if (mode->clock > 297000)
>> @@ -1810,10 +1819,18 @@ static const struct mtk_hdmi_conf mtk_hdmi_conf_mt2701 = {
>>         .tz_disabled = true,
>>  };
>>
>> +static const struct mtk_hdmi_conf mtk_hdmi_conf_mt8167 = {
>> +       .max_mode_clock = 148500,
>> +       .cea_modes_only = true,
>> +};
>> +
>>  static const struct of_device_id mtk_drm_hdmi_of_ids[] = {
>>         { .compatible = "mediatek,mt2701-hdmi",
>>           .data = &mtk_hdmi_conf_mt2701,
>>         },
>> +       { .compatible = "mediatek,mt8167-hdmi",
> 
> "mediatek,mt8167-hdmi" does not exist in binding document, so add this
> to binding document first.
> In addition, could you also transfer mediatek,hdmi.txt to yaml format?

Sure

Thanks,
Neil

> 
> Regards,
> Chun-Kuang.
> 
>> +         .data = &mtk_hdmi_conf_mt8167,
>> +       },
>>         { .compatible = "mediatek,mt8173-hdmi",
>>         },
>>         {}
>> --
>> 2.25.1
>>


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

end of thread, other threads:[~2021-04-12  8:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-09  8:43 [PATCH] gpu/drm: mediatek: hdmi: check for valid modes on MT8167 Neil Armstrong
2021-04-09 22:41 ` Chun-Kuang Hu
2021-04-12  8:26   ` Neil Armstrong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).