Re: [PATCH v2] drm/edid: add CTA Video Format Data Block support
On Mon, 12 Aug 2024, Hamza Mahfooz wrote: > Ping? Sorry, got the spec, but it's a bit involved, and I haven't had the time yet. BR, Jani. -- Jani Nikula, Intel
Re: [PATCH v2] drm/edid: add CTA Video Format Data Block support
Ping?
On 8/2/24 11:53, Hamza Mahfooz wrote:
On 8/1/24 03:35, Jani Nikula wrote:
On Wed, 31 Jul 2024, Hamza Mahfooz wrote:
Video Format Data Blocks (VFDBs) contain the necessary information that
needs to be fed to the Optimized Video Timings (OVT) Algorithm.
Also, we require OVT support to cover modes that aren't supported by
earlier standards (e.g. CVT). So, parse all of the relevant VFDB data
and feed it to the OVT Algorithm, to extract all of the missing OVT
modes.
Suggested-by: Karol Herbst
Signed-off-by: Hamza Mahfooz
---
v2: address comments from Jani
---
drivers/gpu/drm/drm_edid.c | 456 ++---
1 file changed, 428 insertions(+), 28 deletions(-)
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index f68a41eeb1fa..f608ab4e32ae 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -31,6 +31,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -741,6 +742,93 @@ static const struct minimode extra_modes[] = {
{ 2048, 1536, 60, 0 },
};
+struct cta_rid {
+ u16 hactive;
+ u16 vactive;
+ u8 hratio;
+ u8 vratio;
+};
+
+/* CTA-861-I Table 11 - Resolution Identification (RID) */
+static const struct cta_rid rids[] = {
+ /* RID 0-9 */
+ { 0, 0, 0, 0 },
+ { 1280, 720, 16, 9 },
+ { 1280, 720, 64, 27 },
+ { 1680, 720, 64, 27 },
+ { 1920, 1080, 16, 9 },
+ { 1920, 1080, 64, 27 },
+ { 2560, 1080, 64, 27 },
+ { 3840, 1080, 32, 9 },
+ { 2560, 1440, 16, 9 },
+ { 3440, 1440, 64, 27 },
+ /* RID 10-19 */
+ { 5120, 1440, 32, 9 },
+ { 3840, 2160, 16, 9 },
+ { 3840, 2160, 64, 27 },
+ { 5120, 2160, 64, 27 },
+ { 7680, 2160, 32, 9 },
+ { 5120, 2880, 16, 9 },
+ { 5120, 2880, 64, 27 },
+ { 6880, 2880, 64, 27 },
+ { 10240, 2880, 32, 9 },
+ { 7680, 4320, 16, 9 },
+ /* RID 20-28 */
+ { 7680, 4320, 64, 27 },
+ { 10240, 4320, 64, 27 },
+ { 15360, 4320, 32, 9 },
+ { 11520, 6480, 16, 9 },
+ { 11520, 6480, 64, 27 },
+ { 15360, 6480, 64, 27 },
+ { 15360, 8640, 16, 9 },
+ { 15360, 8640, 64, 27 },
+ { 20480, 8640, 64, 27 },
+};
+
+/* CTA-861-I Table 12 - AVI InfoFrame Video Format Frame Rate */
+static const u16 cta_vf_fr[] = {
+ /* Frame Rate 0-7 */
+ 0, 24, 25, 30, 48, 50, 60, 100,
+ /* Frame Rate 8-15 */
+ 120, 144, 200, 240, 300, 360, 400, 480,
+};
+
+/* CTA-861-I Table 13 - RID To VIC Mapping */
+static const u8 rid_to_vic[][8] = {
+ /* RID 0-9 */
+ {},
+ { 60, 61, 62, 108, 19, 4, 41, 47 },
+ { 65, 66, 67, 109, 68, 69, 70, 71 },
+ { 79, 80, 81, 110, 82, 83, 84, 85 },
+ { 32, 33, 34, 111, 31, 16, 64, 63 },
+ { 72, 73, 74, 112, 75, 76, 77, 78 },
+ { 86, 87, 88, 113, 89, 90, 91, 92 },
+ {},
+ {},
+ {},
+ /* RID 10-19 */
+ {},
+ { 93, 94, 95, 114, 96, 97, 117, 118 },
+ { 103, 104, 105, 116, 106, 107, 119, 120 },
+ { 121, 122, 123, 124, 125, 126, 127, 193 },
+ {},
+ {},
+ {},
+ {},
+ {},
+ { 194, 195, 196, 197, 198, 199, 200, 201 },
+ /* RID 20-28 */
+ { 202, 203, 204, 205, 206, 207, 208, 209 },
+ { 210, 211, 212, 213, 214, 215, 216, 217 },
+ {},
+ {},
+ {},
+ {},
+ {},
+ {},
+ {},
+};
+
/*
* From CEA/CTA-861 spec.
*
@@ -4140,6 +4228,7 @@ static int add_detailed_modes(struct
drm_connector *connector,
#define CTA_DB_VIDEO 2
#define CTA_DB_VENDOR 3
#define CTA_DB_SPEAKER 4
+#define CTA_DB_VIDEO_FORMAT 6
#define CTA_DB_EXTENDED_TAG 7
/* CTA-861-H Table 62 - CTA Extended Tag Codes */
@@ -4981,6 +5070,16 @@ struct cea_db {
u8 data[];
} __packed;
+struct cta_vfd {
+ u8 rid;
+ u8 fr_fact;
+ bool bfr50;
+ bool fr24;
+ bool bfr60;
+ bool fr144;
+ bool fr48;
+};
+
static int cea_db_tag(const struct cea_db *db)
{
return db->tag_length >> 5;
@@ -5306,34 +5405,6 @@ static void parse_cta_y420cmdb(struct
drm_connector *connector,
*y420cmdb_map = map;
}
-static int add_cea_modes(struct drm_connector *connector,
- const struct drm_edid *drm_edid)
-{
- const struct cea_db *db;
- struct cea_db_iter iter;
- int modes;
-
- /* CTA VDB block VICs parsed earlier */
- modes = add_cta_vdb_modes(connector);
-
- cea_db_iter_edid_begin(drm_edid, &iter);
- cea_db_iter_for_each(db, &iter) {
- if (cea_db_is_hdmi_vsdb(db)) {
- modes += do_hdmi_vsdb_modes(connector, (const u8 *)db,
- cea_db_payload_len(db));
- } else if (cea_db_is_y420vdb(db)) {
- const u8 *vdb420 = cea_db_data(db) + 1;
-
- /* Add 4:2:0(only) modes present in EDID */
- modes += do_y420vdb_modes(connector, vdb420,
- cea_db_payload_len(db) - 1);
- }
- }
- cea_db_iter_end(&iter);
-
- return modes;
-}
-
Is there anything that really requires moving add_cea_modes() down? You
could just add your new st
Re: [PATCH v2] drm/edid: add CTA Video Format Data Block support
On 8/1/24 03:35, Jani Nikula wrote:
On Wed, 31 Jul 2024, Hamza Mahfooz wrote:
Video Format Data Blocks (VFDBs) contain the necessary information that
needs to be fed to the Optimized Video Timings (OVT) Algorithm.
Also, we require OVT support to cover modes that aren't supported by
earlier standards (e.g. CVT). So, parse all of the relevant VFDB data
and feed it to the OVT Algorithm, to extract all of the missing OVT
modes.
Suggested-by: Karol Herbst
Signed-off-by: Hamza Mahfooz
---
v2: address comments from Jani
---
drivers/gpu/drm/drm_edid.c | 456 ++---
1 file changed, 428 insertions(+), 28 deletions(-)
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index f68a41eeb1fa..f608ab4e32ae 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -31,6 +31,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -741,6 +742,93 @@ static const struct minimode extra_modes[] = {
{ 2048, 1536, 60, 0 },
};
+struct cta_rid {
+ u16 hactive;
+ u16 vactive;
+ u8 hratio;
+ u8 vratio;
+};
+
+/* CTA-861-I Table 11 - Resolution Identification (RID) */
+static const struct cta_rid rids[] = {
+ /* RID 0-9 */
+ { 0, 0, 0, 0 },
+ { 1280, 720, 16, 9 },
+ { 1280, 720, 64, 27 },
+ { 1680, 720, 64, 27 },
+ { 1920, 1080, 16, 9 },
+ { 1920, 1080, 64, 27 },
+ { 2560, 1080, 64, 27 },
+ { 3840, 1080, 32, 9 },
+ { 2560, 1440, 16, 9 },
+ { 3440, 1440, 64, 27 },
+ /* RID 10-19 */
+ { 5120, 1440, 32, 9 },
+ { 3840, 2160, 16, 9 },
+ { 3840, 2160, 64, 27 },
+ { 5120, 2160, 64, 27 },
+ { 7680, 2160, 32, 9 },
+ { 5120, 2880, 16, 9 },
+ { 5120, 2880, 64, 27 },
+ { 6880, 2880, 64, 27 },
+ { 10240, 2880, 32, 9 },
+ { 7680, 4320, 16, 9 },
+ /* RID 20-28 */
+ { 7680, 4320, 64, 27 },
+ { 10240, 4320, 64, 27 },
+ { 15360, 4320, 32, 9 },
+ { 11520, 6480, 16, 9 },
+ { 11520, 6480, 64, 27 },
+ { 15360, 6480, 64, 27 },
+ { 15360, 8640, 16, 9 },
+ { 15360, 8640, 64, 27 },
+ { 20480, 8640, 64, 27 },
+};
+
+/* CTA-861-I Table 12 - AVI InfoFrame Video Format Frame Rate */
+static const u16 cta_vf_fr[] = {
+ /* Frame Rate 0-7 */
+ 0, 24, 25, 30, 48, 50, 60, 100,
+ /* Frame Rate 8-15 */
+ 120, 144, 200, 240, 300, 360, 400, 480,
+};
+
+/* CTA-861-I Table 13 - RID To VIC Mapping */
+static const u8 rid_to_vic[][8] = {
+ /* RID 0-9 */
+ {},
+ { 60, 61, 62, 108, 19, 4, 41, 47 },
+ { 65, 66, 67, 109, 68, 69, 70, 71 },
+ { 79, 80, 81, 110, 82, 83, 84, 85 },
+ { 32, 33, 34, 111, 31, 16, 64, 63 },
+ { 72, 73, 74, 112, 75, 76, 77, 78 },
+ { 86, 87, 88, 113, 89, 90, 91, 92 },
+ {},
+ {},
+ {},
+ /* RID 10-19 */
+ {},
+ { 93, 94, 95, 114, 96, 97, 117, 118 },
+ { 103, 104, 105, 116, 106, 107, 119, 120 },
+ { 121, 122, 123, 124, 125, 126, 127, 193 },
+ {},
+ {},
+ {},
+ {},
+ {},
+ { 194, 195, 196, 197, 198, 199, 200, 201 },
+ /* RID 20-28 */
+ { 202, 203, 204, 205, 206, 207, 208, 209 },
+ { 210, 211, 212, 213, 214, 215, 216, 217 },
+ {},
+ {},
+ {},
+ {},
+ {},
+ {},
+ {},
+};
+
/*
* From CEA/CTA-861 spec.
*
@@ -4140,6 +4228,7 @@ static int add_detailed_modes(struct drm_connector
*connector,
#define CTA_DB_VIDEO 2
#define CTA_DB_VENDOR 3
#define CTA_DB_SPEAKER4
+#define CTA_DB_VIDEO_FORMAT6
#define CTA_DB_EXTENDED_TAG 7
/* CTA-861-H Table 62 - CTA Extended Tag Codes */
@@ -4981,6 +5070,16 @@ struct cea_db {
u8 data[];
} __packed;
+struct cta_vfd {
+ u8 rid;
+ u8 fr_fact;
+ bool bfr50;
+ bool fr24;
+ bool bfr60;
+ bool fr144;
+ bool fr48;
+};
+
static int cea_db_tag(const struct cea_db *db)
{
return db->tag_length >> 5;
@@ -5306,34 +5405,6 @@ static void parse_cta_y420cmdb(struct drm_connector
*connector,
*y420cmdb_map = map;
}
-static int add_cea_modes(struct drm_connector *connector,
-const struct drm_edid *drm_edid)
-{
- const struct cea_db *db;
- struct cea_db_iter iter;
- int modes;
-
- /* CTA VDB block VICs parsed earlier */
- modes = add_cta_vdb_modes(connector);
-
- cea_db_iter_edid_begin(drm_edid, &iter);
- cea_db_iter_for_each(db, &iter) {
- if (cea_db_is_hdmi_vsdb(db)) {
- modes += do_hdmi_vsdb_modes(connector, (const u8 *)db,
- cea_db_payload_len(db));
- } else if (cea_db_is_y420vdb(db)) {
- const u8 *vdb420 = cea_db_data(db) + 1;
-
-
Re: [PATCH v2] drm/edid: add CTA Video Format Data Block support
On Wed, 31 Jul 2024, Hamza Mahfooz wrote:
> Video Format Data Blocks (VFDBs) contain the necessary information that
> needs to be fed to the Optimized Video Timings (OVT) Algorithm.
> Also, we require OVT support to cover modes that aren't supported by
> earlier standards (e.g. CVT). So, parse all of the relevant VFDB data
> and feed it to the OVT Algorithm, to extract all of the missing OVT
> modes.
>
> Suggested-by: Karol Herbst
> Signed-off-by: Hamza Mahfooz
> ---
> v2: address comments from Jani
> ---
> drivers/gpu/drm/drm_edid.c | 456 ++---
> 1 file changed, 428 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index f68a41eeb1fa..f608ab4e32ae 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -31,6 +31,7 @@
> #include
> #include
> #include
> +#include
> #include
> #include
> #include
> @@ -741,6 +742,93 @@ static const struct minimode extra_modes[] = {
> { 2048, 1536, 60, 0 },
> };
>
> +struct cta_rid {
> + u16 hactive;
> + u16 vactive;
> + u8 hratio;
> + u8 vratio;
> +};
> +
> +/* CTA-861-I Table 11 - Resolution Identification (RID) */
> +static const struct cta_rid rids[] = {
> + /* RID 0-9 */
> + { 0, 0, 0, 0 },
> + { 1280, 720, 16, 9 },
> + { 1280, 720, 64, 27 },
> + { 1680, 720, 64, 27 },
> + { 1920, 1080, 16, 9 },
> + { 1920, 1080, 64, 27 },
> + { 2560, 1080, 64, 27 },
> + { 3840, 1080, 32, 9 },
> + { 2560, 1440, 16, 9 },
> + { 3440, 1440, 64, 27 },
> + /* RID 10-19 */
> + { 5120, 1440, 32, 9 },
> + { 3840, 2160, 16, 9 },
> + { 3840, 2160, 64, 27 },
> + { 5120, 2160, 64, 27 },
> + { 7680, 2160, 32, 9 },
> + { 5120, 2880, 16, 9 },
> + { 5120, 2880, 64, 27 },
> + { 6880, 2880, 64, 27 },
> + { 10240, 2880, 32, 9 },
> + { 7680, 4320, 16, 9 },
> + /* RID 20-28 */
> + { 7680, 4320, 64, 27 },
> + { 10240, 4320, 64, 27 },
> + { 15360, 4320, 32, 9 },
> + { 11520, 6480, 16, 9 },
> + { 11520, 6480, 64, 27 },
> + { 15360, 6480, 64, 27 },
> + { 15360, 8640, 16, 9 },
> + { 15360, 8640, 64, 27 },
> + { 20480, 8640, 64, 27 },
> +};
> +
> +/* CTA-861-I Table 12 - AVI InfoFrame Video Format Frame Rate */
> +static const u16 cta_vf_fr[] = {
> + /* Frame Rate 0-7 */
> + 0, 24, 25, 30, 48, 50, 60, 100,
> + /* Frame Rate 8-15 */
> + 120, 144, 200, 240, 300, 360, 400, 480,
> +};
> +
> +/* CTA-861-I Table 13 - RID To VIC Mapping */
> +static const u8 rid_to_vic[][8] = {
> + /* RID 0-9 */
> + {},
> + { 60, 61, 62, 108, 19, 4, 41, 47 },
> + { 65, 66, 67, 109, 68, 69, 70, 71 },
> + { 79, 80, 81, 110, 82, 83, 84, 85 },
> + { 32, 33, 34, 111, 31, 16, 64, 63 },
> + { 72, 73, 74, 112, 75, 76, 77, 78 },
> + { 86, 87, 88, 113, 89, 90, 91, 92 },
> + {},
> + {},
> + {},
> + /* RID 10-19 */
> + {},
> + { 93, 94, 95, 114, 96, 97, 117, 118 },
> + { 103, 104, 105, 116, 106, 107, 119, 120 },
> + { 121, 122, 123, 124, 125, 126, 127, 193 },
> + {},
> + {},
> + {},
> + {},
> + {},
> + { 194, 195, 196, 197, 198, 199, 200, 201 },
> + /* RID 20-28 */
> + { 202, 203, 204, 205, 206, 207, 208, 209 },
> + { 210, 211, 212, 213, 214, 215, 216, 217 },
> + {},
> + {},
> + {},
> + {},
> + {},
> + {},
> + {},
> +};
> +
> /*
> * From CEA/CTA-861 spec.
> *
> @@ -4140,6 +4228,7 @@ static int add_detailed_modes(struct drm_connector
> *connector,
> #define CTA_DB_VIDEO 2
> #define CTA_DB_VENDOR3
> #define CTA_DB_SPEAKER 4
> +#define CTA_DB_VIDEO_FORMAT 6
> #define CTA_DB_EXTENDED_TAG 7
>
> /* CTA-861-H Table 62 - CTA Extended Tag Codes */
> @@ -4981,6 +5070,16 @@ struct cea_db {
> u8 data[];
> } __packed;
>
> +struct cta_vfd {
> + u8 rid;
> + u8 fr_fact;
> + bool bfr50;
> + bool fr24;
> + bool bfr60;
> + bool fr144;
> + bool fr48;
> +};
> +
> static int cea_db_tag(const struct cea_db *db)
> {
> return db->tag_length >> 5;
> @@ -5306,34 +5405,6 @@ static void parse_cta_y420cmdb(struct drm_connector
> *connector,
> *y420cmdb_map = map;
> }
>
> -static int add_cea_modes(struct drm_connector *connector,
> - const struct drm_edid *drm_edid)
> -{
> - const struct cea_db *db;
> - struct cea_db_iter iter;
> - int modes;
> -
> - /* CTA VDB block VICs parsed earlier */
> - modes = add_cta_vdb_modes(connector);
> -
> - cea_db_iter_edid_begin(drm_edid, &iter);
> - cea_db_iter_for_each(db, &iter) {
> - if (cea_db_is_hdmi_vsdb(db)) {
> - modes += do_hdmi_vsdb_modes(connector, (const u8 *)db,
> - cea_db_payload_len(db));
> - } else if (cea_db_is_y420vdb(db)) {
