Skip to contentSkip to conversation

fbdev: add cea modes and properties

PATCH In review [email protected] 3 participants 3 messages May 27, 2014 – Jun 24, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fbdev: add cea modes and properties

From: Christopher Freeman <[email protected]>

This is a port of two patches from Android source to fill in all 64 cea modes as well as specify the aspect ratios for those modes.

Changes were:

69f54f5 - video: fbmon: Add support for CEA pixel ratios. <Lajos Molnar> 2082e82 - video: fbmon: add remaining modes to CEA mode database <Erik Gilling>

There was one correction to CEA mode 1 which had an incorrect lower margin (should be 10, was 1)

---
 drivers/video/fbdev/core/fbmon.c  |  14 +-
 drivers/video/fbdev/core/modedb.c | 572 ++++++++++++++++++++++++++++++++++----
 include/linux/fb.h                |   3 +-
 include/uapi/linux/fb.h           |   4 +
 4 files changed, 533 insertions(+), 60 deletions(-)
drivers/video/fbdev/core/fbmon.c +11 -3
index c204ebe..6041383 100644
@@ -553,6 +553,9 @@ static int get_dst_timing(unsigned char *block,
 static void get_detailed_timing(unsigned char *block,
 				struct fb_videomode *mode)
 {
+	int v_size = V_SIZE;
+	int h_size = H_SIZE;
+
 	mode->xres = H_ACTIVE;
 	mode->yres = V_ACTIVE;
 	mode->pixclock = PIXEL_CLOCK;
@@ -581,11 +584,18 @@ static void get_detailed_timing(unsigned char *block,
 	}
 	mode->flag = FB_MODE_IS_DETAILED;
 
+	/* get aspect ratio */
+	if (h_size * 18 > v_size * 31 && h_size * 18 < v_size * 33)
+		mode->flag |= FB_FLAG_RATIO_16_9;
+	if (h_size * 18 > v_size * 23 && h_size * 18 < v_size * 25)
+		mode->flag |= FB_FLAG_RATIO_4_3;
+
 	DPRINTK("      %d MHz ",  PIXEL_CLOCK/1000000);
 	DPRINTK("%d %d %d %d ", H_ACTIVE, H_ACTIVE + H_SYNC_OFFSET,
 	       H_ACTIVE + H_SYNC_OFFSET + H_SYNC_WIDTH, H_ACTIVE + H_BLANKING);
 	DPRINTK("%d %d %d %d ", V_ACTIVE, V_ACTIVE + V_SYNC_OFFSET,
 	       V_ACTIVE + V_SYNC_OFFSET + V_SYNC_WIDTH, V_ACTIVE + V_BLANKING);
+	DPRINTK("%dmm %dmm ", H_SIZE, V_SIZE);
 	DPRINTK("%sHSync %sVSync\n\n", (HSYNC_POSITIVE) ? "+" : "-",
 	       (VSYNC_POSITIVE) ? "+" : "-");
 }
@@ -1052,10 +1062,8 @@ void fb_edid_add_monspecs(unsigned char *edid, struct fb_monspecs *specs)
 
 	for (i = specs->modedb_len + num; i < specs->modedb_len + num + svd_n; i++) {
 		int idx = svd[i - specs->modedb_len - num];
-		if (!idx || idx > 63) {
+		if (!idx || idx > (CEA_MODEDB_SIZE - 1)) {
 			pr_warning("Reserved SVD code %d\n", idx);
-		} else if (idx > ARRAY_SIZE(cea_modes) || !cea_modes[idx].xres) {
-			pr_warning("Unimplemented SVD code %d\n", idx);
 		} else {
 			memcpy(&m[i], cea_modes + idx, sizeof(m[i]));
 			pr_debug("Adding SVD #%d: %ux%u@%u\n", idx,
drivers/video/fbdev/core/modedb.c +516 -56

580 lines not on this page · raw message

include/linux/fb.h +2 -1
index fe6ac95..1035902 100644
@@ -726,6 +726,7 @@ extern int fb_videomode_from_videomode(const struct videomode *vm,
 
 /* drivers/video/modedb.c */
 #define VESA_MODEDB_SIZE 34
+#define CEA_MODEDB_SIZE 65
 extern void fb_var_to_videomode(struct fb_videomode *mode,
 				const struct fb_var_screeninfo *var);
 extern void fb_videomode_to_var(struct fb_var_screeninfo *var,
@@ -778,7 +779,7 @@ struct fb_videomode {
 
 extern const char *fb_mode_option;
 extern const struct fb_videomode vesa_modes[];
-extern const struct fb_videomode cea_modes[64];
+extern const struct fb_videomode cea_modes[];
 
 struct fb_modelist {
 	struct list_head list;
include/uapi/linux/fb.h +4 -0
index fb795c3..a65a787 100644
@@ -226,6 +226,10 @@ struct fb_bitfield {
 #define FB_VMODE_SMOOTH_XPAN	512	/* smooth xpan possible (internally used) */
 #define FB_VMODE_CONUPDATE	512	/* don't update x/yoffset	*/
 
+#define FB_FLAG_RATIO_4_3	64
+#define FB_FLAG_RATIO_16_9	128
+#define FB_FLAG_PIXEL_REPEAT	256
+
 /*
  * Display rotation support
  */
Signature · 9 lines
1.8.3.2


-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------
#1 lore raw

Hi,

Quoted 4 lines · On 27/05/14 04:17, [email protected] wrote:

From: Christopher Freeman <[email protected]>

This is a port of two patches from Android source to fill in all 64 cea modes as well as specify the aspect ratios for those modes.

I was testing this a bit with omapfb and my monitor. I don't see the aspect ratio flags set properly for all modes for some reason.

This is a debug print of the modes from my monitor, from the modedb after adding two EDID blocks to it.

0: 1920x1200 pck 154012000, sync 2, vmode 0, flags 11: detailed first 1: 720x400 pck 26171000, sync 0, vmode 0, flags 8: calc
2: 640x480 pck 25200000, sync 0, vmode 0, flags 4: vesa
3: 640x480 pck 31500000, sync 0, vmode 0, flags 4: vesa
4: 800x600 pck 40000000, sync 3, vmode 0, flags 4: vesa
5: 800x600 pck 49500000, sync 3, vmode 0, flags 4: vesa
6: 832x624 pck 53433000, sync 0, vmode 0, flags 8: calc
7: 1024x768 pck 65002000, sync 0, vmode 0, flags 4: vesa 8: 1024x768 pck 78802000, sync 3, vmode 0, flags 4: vesa 9: 1280x1024 pck 135007000, sync 3, vmode 0, flags 4: vesa 10: 1152x864 pck 108003000, sync 3, vmode 0, flags 4: vesa 11: 1280x960 pck 108003000, sync 3, vmode 0, flags 6: standard vesa 12: 1600x1000 pck 132802000, sync 0, vmode 0, flags 0:
13: 1600x1200 pck 162022000, sync 3, vmode 0, flags 6: standard vesa 14: 1680x1050 pck 146864000, sync 0, vmode 0, flags 0:
15: 1920x1200 pck 193236000, sync 0, vmode 0, flags 0:
16: 1920x1080 pck 74250000, sync 3, vmode 1, flags 11: detailed first 17: 1920x1080 pck 74250000, sync 3, vmode 1, flags 1: detailed 18: 1280x720 pck 74250000, sync 3, vmode 0, flags 1: detailed 19: 1280x720 pck 74250000, sync 3, vmode 0, flags 1: detailed 20: 1920x1080 pck 74250000, sync 3, vmode 1, flags 80: 16:9 21: 1440x480 pck 27000000, sync 0, vmode 1, flags 140: 4:3 repeat 22: 1920x1080 pck 148500000, sync 3, vmode 0, flags 80: 16:9 23: 720x576 pck 27000000, sync 0, vmode 0, flags 40: 4:3 24: 1280x720 pck 74250000, sync 3, vmode 0, flags 80: 16:9 25: 1920x1080 pck 74250000, sync 3, vmode 1, flags 80: 16:9 26: 1440x576 pck 27000000, sync 0, vmode 1, flags 140: 4:3 repeat 27: 1920x1080 pck 148500000, sync 3, vmode 0, flags 80: 16:9 28: 2880x480 pck 108003000, sync 0, vmode 0, flags 140: 4:3 repeat 29: 1440x240 pck 27000000, sync 0, vmode 0, flags 180: 16:9 repeat 30: 1440x480 pck 27000000, sync 0, vmode 1, flags 180: 16:9 repeat

For some reason some of the 16:9 modes do not have the flag, like mode
16. Any ideas?

include/uapi/linux/fb.h struct fb_bitfield { · line 232

Quoted 12 lines
include/uapi/linux/fb.h +4 -0
index fb795c3..a65a787 100644
@@ -226,6 +226,10 @@ struct fb_bitfield {
 #define FB_VMODE_SMOOTH_XPAN	512	/* smooth xpan possible (internally used) */
 #define FB_VMODE_CONUPDATE	512	/* don't update x/yoffset	*/
 
+#define FB_FLAG_RATIO_4_3	64
+#define FB_FLAG_RATIO_16_9	128
+#define FB_FLAG_PIXEL_REPEAT	256
+

The rest of the bits are defined in include/linux/fb.h. Why did you add these three bits here?

Tomi

#2 lore raw
In reply to [email protected]

Oops. Please reply to this address instead of the iki.fi one.

Tomi

Quoted 68 lines · Tomi Valkeinen

Hi,

Quoted 4 lines · On 27/05/14 04:17, [email protected] wrote:

From: Christopher Freeman <[email protected]>

This is a port of two patches from Android source to fill in all 64 cea modes as well as specify the aspect ratios for those modes.

I was testing this a bit with omapfb and my monitor. I don't see the aspect ratio flags set properly for all modes for some reason.

This is a debug print of the modes from my monitor, from the modedb after adding two EDID blocks to it.

0: 1920x1200 pck 154012000, sync 2, vmode 0, flags 11: detailed first 1: 720x400 pck 26171000, sync 0, vmode 0, flags 8: calc
2: 640x480 pck 25200000, sync 0, vmode 0, flags 4: vesa
3: 640x480 pck 31500000, sync 0, vmode 0, flags 4: vesa
4: 800x600 pck 40000000, sync 3, vmode 0, flags 4: vesa
5: 800x600 pck 49500000, sync 3, vmode 0, flags 4: vesa
6: 832x624 pck 53433000, sync 0, vmode 0, flags 8: calc
7: 1024x768 pck 65002000, sync 0, vmode 0, flags 4: vesa 8: 1024x768 pck 78802000, sync 3, vmode 0, flags 4: vesa 9: 1280x1024 pck 135007000, sync 3, vmode 0, flags 4: vesa 10: 1152x864 pck 108003000, sync 3, vmode 0, flags 4: vesa 11: 1280x960 pck 108003000, sync 3, vmode 0, flags 6: standard vesa 12: 1600x1000 pck 132802000, sync 0, vmode 0, flags 0:
13: 1600x1200 pck 162022000, sync 3, vmode 0, flags 6: standard vesa 14: 1680x1050 pck 146864000, sync 0, vmode 0, flags 0:
15: 1920x1200 pck 193236000, sync 0, vmode 0, flags 0:
16: 1920x1080 pck 74250000, sync 3, vmode 1, flags 11: detailed first 17: 1920x1080 pck 74250000, sync 3, vmode 1, flags 1: detailed 18: 1280x720 pck 74250000, sync 3, vmode 0, flags 1: detailed 19: 1280x720 pck 74250000, sync 3, vmode 0, flags 1: detailed 20: 1920x1080 pck 74250000, sync 3, vmode 1, flags 80: 16:9 21: 1440x480 pck 27000000, sync 0, vmode 1, flags 140: 4:3 repeat 22: 1920x1080 pck 148500000, sync 3, vmode 0, flags 80: 16:9 23: 720x576 pck 27000000, sync 0, vmode 0, flags 40: 4:3 24: 1280x720 pck 74250000, sync 3, vmode 0, flags 80: 16:9 25: 1920x1080 pck 74250000, sync 3, vmode 1, flags 80: 16:9 26: 1440x576 pck 27000000, sync 0, vmode 1, flags 140: 4:3 repeat 27: 1920x1080 pck 148500000, sync 3, vmode 0, flags 80: 16:9 28: 2880x480 pck 108003000, sync 0, vmode 0, flags 140: 4:3 repeat 29: 1440x240 pck 27000000, sync 0, vmode 0, flags 180: 16:9 repeat 30: 1440x480 pck 27000000, sync 0, vmode 1, flags 180: 16:9 repeat

For some reason some of the 16:9 modes do not have the flag, like mode
16. Any ideas?

include/uapi/linux/fb.h struct fb_bitfield { · line 232

Quoted 12 lines
include/uapi/linux/fb.h +4 -0
index fb795c3..a65a787 100644
@@ -226,6 +226,10 @@ struct fb_bitfield {
 #define FB_VMODE_SMOOTH_XPAN	512	/* smooth xpan possible (internally used) */
 #define FB_VMODE_CONUPDATE	512	/* don't update x/yoffset	*/
 
+#define FB_FLAG_RATIO_4_3	64
+#define FB_FLAG_RATIO_16_9	128
+#define FB_FLAG_PIXEL_REPEAT	256
+

The rest of the bits are defined in include/linux/fb.h. Why did you add these three bits here?

Tomi