Skip to content

Commit 60251e8

Browse files
committed
video: mxc_hdmi: Add new option 'auto' for RGB Quant Range setting
This new option, which is now the default, will automatically use full range, when the sink announces that it supports quantisation overriding. Otherwise, the default range (i.e. limited) is used. Signed-off-by: Rudi <r.ihle@s-t.de>
1 parent 805856e commit 60251e8

File tree

1 file changed

+32
-9
lines changed

1 file changed

+32
-9
lines changed

drivers/video/mxc/mxc_hdmi.c

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,11 @@ extern int mxcfb_blank(int blank, struct fb_info *info);
216216
static void mxc_hdmi_setup(struct mxc_hdmi *hdmi, unsigned long event);
217217
static void hdmi_enable_overflow_interrupts(void);
218218
static void hdmi_disable_overflow_interrupts(void);
219+
static unsigned int getRGBQuantRange(struct mxc_hdmi *hdmi);
219220

220-
static char *rgb_quant_range = "default";
221+
static char *rgb_quant_range = "auto";
221222
module_param(rgb_quant_range, charp, S_IRUGO);
222-
MODULE_PARM_DESC(rgb_quant_range, "RGB Quant Range (default, limited, full)");
223+
MODULE_PARM_DESC(rgb_quant_range, "RGB Quant Range (auto, default, limited, full)");
223224

224225
static struct platform_device_id imx_hdmi_devtype[] = {
225226
{
@@ -355,8 +356,9 @@ static ssize_t mxc_hdmi_show_rgb_quant_range(struct device *dev,
355356
struct device_attribute *attr, char *buf)
356357
{
357358
struct mxc_hdmi *hdmi = dev_get_drvdata(dev);
359+
int n;
358360

359-
switch (hdmi->hdmi_data.rgb_quant_range) {
361+
switch (getRGBQuantRange(hdmi)) {
360362
case HDMI_FC_AVICONF2_RGB_QUANT_LIMITED_RANGE:
361363
strcpy(buf, "limited\n");
362364
break;
@@ -369,7 +371,14 @@ static ssize_t mxc_hdmi_show_rgb_quant_range(struct device *dev,
369371
break;
370372
};
371373

372-
return strlen(buf);
374+
n = strlen(buf);
375+
376+
if (hdmi->hdmi_data.rgb_quant_range == HDMI_FC_AVICONF2_RGB_QUANT_MASK) {
377+
strcpy(buf + n - 1, " (auto)\n");
378+
n += 7;
379+
}
380+
381+
return n;
373382
}
374383

375384
static ssize_t mxc_hdmi_store_rgb_quant_range(struct device *dev,
@@ -384,6 +393,8 @@ static ssize_t mxc_hdmi_store_rgb_quant_range(struct device *dev,
384393
hdmi->hdmi_data.rgb_quant_range = HDMI_FC_AVICONF2_RGB_QUANT_FULL_RANGE;
385394
} else if (sysfs_streq("default", buf)) {
386395
hdmi->hdmi_data.rgb_quant_range = HDMI_FC_AVICONF2_RGB_QUANT_DEFAULT;
396+
} else if (sysfs_streq("auto", buf)) {
397+
hdmi->hdmi_data.rgb_quant_range = HDMI_FC_AVICONF2_RGB_QUANT_MASK;
387398
} else {
388399
ret = -EINVAL;
389400
goto out;
@@ -510,12 +521,23 @@ static void hdmi_video_sample(struct mxc_hdmi *hdmi)
510521
hdmi_writeb(0x0, HDMI_TX_BCBDATA1);
511522
}
512523

524+
static unsigned int getRGBQuantRange(struct mxc_hdmi *hdmi)
525+
{
526+
if (hdmi->hdmi_data.rgb_quant_range != HDMI_FC_AVICONF2_RGB_QUANT_MASK)
527+
return hdmi->hdmi_data.rgb_quant_range;
528+
529+
return hdmi->edid_cfg.cea_rgb_range_selectable ?
530+
HDMI_FC_AVICONF2_RGB_QUANT_FULL_RANGE : HDMI_FC_AVICONF2_RGB_QUANT_DEFAULT;
531+
}
532+
513533
static int isColorSpaceConversion(struct mxc_hdmi *hdmi)
514534
{
535+
unsigned int rgb_quant_range = getRGBQuantRange(hdmi);
536+
515537
return (hdmi->hdmi_data.enc_in_format != hdmi->hdmi_data.enc_out_format) ||
516538
(hdmi->hdmi_data.enc_out_format == RGB &&
517-
((hdmi->hdmi_data.rgb_quant_range == HDMI_FC_AVICONF2_RGB_QUANT_LIMITED_RANGE) ||
518-
(hdmi->hdmi_data.rgb_quant_range == HDMI_FC_AVICONF2_RGB_QUANT_DEFAULT && hdmi->vic > 1)));
539+
((rgb_quant_range == HDMI_FC_AVICONF2_RGB_QUANT_LIMITED_RANGE) ||
540+
(rgb_quant_range == HDMI_FC_AVICONF2_RGB_QUANT_DEFAULT && hdmi->vic > 1)));
519541
}
520542

521543
static int isColorSpaceDecimation(struct mxc_hdmi *hdmi)
@@ -1475,8 +1497,7 @@ static void hdmi_config_AVI(struct mxc_hdmi *hdmi)
14751497
********************************************/
14761498

14771499
val = HDMI_FC_AVICONF2_IT_CONTENT_NO_DATA | ext_colorimetry |
1478-
hdmi->hdmi_data.rgb_quant_range |
1479-
HDMI_FC_AVICONF2_SCALING_NONE;
1500+
getRGBQuantRange(hdmi) | HDMI_FC_AVICONF2_SCALING_NONE;
14801501
hdmi_writeb(val, HDMI_FC_AVICONF2);
14811502

14821503
/********************************************
@@ -2798,8 +2819,10 @@ static int mxc_hdmi_disp_init(struct mxc_dispdrv_handle *disp,
27982819
hdmi->hdmi_data.rgb_quant_range = HDMI_FC_AVICONF2_RGB_QUANT_LIMITED_RANGE;
27992820
} else if (!strcasecmp(rgb_quant_range, "full")) {
28002821
hdmi->hdmi_data.rgb_quant_range = HDMI_FC_AVICONF2_RGB_QUANT_FULL_RANGE;
2801-
} else {
2822+
} else if (!strcasecmp(rgb_quant_range, "default")) {
28022823
hdmi->hdmi_data.rgb_quant_range = HDMI_FC_AVICONF2_RGB_QUANT_DEFAULT;
2824+
} else {
2825+
hdmi->hdmi_data.rgb_quant_range = HDMI_FC_AVICONF2_RGB_QUANT_MASK;
28032826
}
28042827

28052828
ret = devm_request_irq(&hdmi->pdev->dev, irq, mxc_hdmi_hotplug, IRQF_SHARED,

0 commit comments

Comments
 (0)