mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 11:50:43 +09:00
hdmitx: rewrite allm / contenttype [1/1]
PD#SWPL-14891 Problem: need rewrite allm / contenttype Solution: rewrite allm / contenttype Verify: G12/U212 Change-Id: I3a41c963b1ba359546ed1286cc5c587f579aa441 Signed-off-by: Zongdong Jiao <zongdong.jiao@amlogic.com>
This commit is contained in:
@@ -1620,7 +1620,6 @@ static int hdmitx_edid_block_parse(struct hdmitx_dev *hdmitx_device,
|
||||
set_vsdb_dc_cap(prxcap);
|
||||
prxcap->Max_TMDS_Clock1 =
|
||||
(count > 6) ? blockbuf[offset + 6] : 0;
|
||||
|
||||
if (count > 7) {
|
||||
tmp = blockbuf[offset + 7];
|
||||
idx = offset + 8;
|
||||
@@ -1640,6 +1639,10 @@ static int hdmitx_edid_block_parse(struct hdmitx_dev *hdmitx_device,
|
||||
get_ilatency(prxcap, val);
|
||||
idx += 2;
|
||||
}
|
||||
prxcap->cnc0 = (tmp >> 0) & 1;
|
||||
prxcap->cnc1 = (tmp >> 1) & 1;
|
||||
prxcap->cnc2 = (tmp >> 2) & 1;
|
||||
prxcap->cnc3 = (tmp >> 3) & 1;
|
||||
if (tmp & (1<<5)) {
|
||||
idx += 1;
|
||||
/* valid 4k */
|
||||
|
||||
@@ -2839,73 +2839,122 @@ static ssize_t store_valid_mode(struct device *dev,
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t show_allm_cap(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
int pos = 0;
|
||||
struct rx_cap *prxcap = &hdmitx_device.rxcap;
|
||||
|
||||
pos += snprintf(buf + pos, PAGE_SIZE, "%d\n\r", prxcap->allm);
|
||||
return pos;
|
||||
}
|
||||
|
||||
static ssize_t show_allm_mode(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
int pos = 0;
|
||||
struct hdmitx_dev *hdev = &hdmitx_device;
|
||||
struct rx_cap *prxcap = &hdmitx_device.rxcap;
|
||||
|
||||
if (!prxcap->allm) { /* Rx not support ALLM */
|
||||
pos += snprintf(buf + pos, PAGE_SIZE, "0\n\r");
|
||||
return pos;
|
||||
}
|
||||
|
||||
if (hdev->allm_mode == 1)
|
||||
pos += snprintf(buf + pos, PAGE_SIZE, "game\n\r");
|
||||
else if (hdev->allm_mode == 2)
|
||||
pos += snprintf(buf + pos, PAGE_SIZE, "graphics\n\r");
|
||||
else if (hdev->allm_mode == 3)
|
||||
pos += snprintf(buf + pos, PAGE_SIZE, "photo\n\r");
|
||||
else if (hdev->allm_mode == 4)
|
||||
pos += snprintf(buf + pos, PAGE_SIZE, "cinema\n\r");
|
||||
else
|
||||
pos += snprintf(buf + pos, PAGE_SIZE, "0\n\r");
|
||||
pos += snprintf(buf + pos, PAGE_SIZE, "%d\n\r", hdev->allm_mode);
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
static inline int com_str(const char *buf, const char *str)
|
||||
{
|
||||
return strncmp(buf, str, strlen(str)) == 0;
|
||||
}
|
||||
static ssize_t store_allm_mode(struct device *dev,
|
||||
struct device_attribute *attr, const char *buf, size_t count)
|
||||
{
|
||||
struct hdmitx_dev *hdev = &hdmitx_device;
|
||||
struct rx_cap *prxcap = &hdev->rxcap;
|
||||
|
||||
pr_info("hdmitx: store allm_mode as %s\n", buf);
|
||||
|
||||
if (!prxcap->allm) /* Rx not support ALLM */
|
||||
return count;
|
||||
|
||||
#define CMP_STR(str) (strncmp(buf, str, strlen(str)) == 0)
|
||||
if (CMP_STR("0")) {
|
||||
if (com_str(buf, "0")) {
|
||||
// disable ALLM
|
||||
hdev->allm_mode = 0;
|
||||
hdev->hwop.cntlconfig(hdev, CONF_ALLM_MODE, CLEAR_ALLM_MODE);
|
||||
hdmitx_construct_vsif(hdev, VT_ALLM, 0, NULL);
|
||||
if (is_hdmi14_4k(hdev->cur_VIC))
|
||||
hdmitx_construct_vsif(hdev, VT_HDMI14_4K, 1, NULL);
|
||||
return count;
|
||||
}
|
||||
if (CMP_STR("1") || CMP_STR("game") || CMP_STR("graphics")
|
||||
|| CMP_STR("photo") || CMP_STR("cinema")) {
|
||||
hdmitx_construct_vsif(hdev, VT_ALLM, 1, NULL);
|
||||
}
|
||||
if (CMP_STR("1") || CMP_STR("game")) {
|
||||
if (com_str(buf, "1")) {
|
||||
hdev->allm_mode = 1;
|
||||
// enable the default GAME ALLM
|
||||
hdev->hwop.cntlconfig(hdev, CONF_ALLM_MODE, SET_ALLM_GAME);
|
||||
hdmitx_construct_vsif(hdev, VT_ALLM, 1, NULL);
|
||||
hdev->hwop.cntlconfig(hdev, CONF_CT_MODE, SET_CT_OFF);
|
||||
}
|
||||
if (CMP_STR("graphics")) {
|
||||
hdev->allm_mode = 2;
|
||||
hdev->hwop.cntlconfig(hdev, CONF_ALLM_MODE, SET_ALLM_GRAPHICS);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t show_contenttype_cap(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
int pos = 0;
|
||||
struct rx_cap *prxcap = &hdmitx_device.rxcap;
|
||||
|
||||
if (prxcap->cnc0)
|
||||
pos += snprintf(buf + pos, PAGE_SIZE, "graphics\n\r");
|
||||
if (prxcap->cnc1)
|
||||
pos += snprintf(buf + pos, PAGE_SIZE, "photo\n\r");
|
||||
if (prxcap->cnc2)
|
||||
pos += snprintf(buf + pos, PAGE_SIZE, "cinema\n\r");
|
||||
if (prxcap->cnc3)
|
||||
pos += snprintf(buf + pos, PAGE_SIZE, "game\n\r");
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
static ssize_t show_contenttype_mode(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
int pos = 0;
|
||||
struct hdmitx_dev *hdev = &hdmitx_device;
|
||||
|
||||
if (hdev->ct_mode == 0)
|
||||
pos += snprintf(buf + pos, PAGE_SIZE, "off\n\r");
|
||||
if (hdev->ct_mode == 1)
|
||||
pos += snprintf(buf + pos, PAGE_SIZE, "game\n\r");
|
||||
if (hdev->ct_mode == 2)
|
||||
pos += snprintf(buf + pos, PAGE_SIZE, "graphics\n\r");
|
||||
if (hdev->ct_mode == 3)
|
||||
pos += snprintf(buf + pos, PAGE_SIZE, "photo\n\r");
|
||||
if (hdev->ct_mode == 4)
|
||||
pos += snprintf(buf + pos, PAGE_SIZE, "cinema\n\r");
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
static ssize_t store_contenttype_mode(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
struct hdmitx_dev *hdev = &hdmitx_device;
|
||||
|
||||
pr_info("hdmitx: store contenttype_mode as %s\n", buf);
|
||||
|
||||
hdev->allm_mode = 0;
|
||||
hdmitx_construct_vsif(hdev, VT_ALLM, 0, NULL);
|
||||
if (is_hdmi14_4k(hdev->cur_VIC))
|
||||
hdmitx_construct_vsif(hdev, VT_HDMI14_4K, 1, NULL);
|
||||
hdev->ct_mode = 0;
|
||||
hdev->hwop.cntlconfig(hdev, CONF_CT_MODE, SET_CT_OFF);
|
||||
|
||||
if (com_str(buf, "1") || com_str(buf, "game")) {
|
||||
hdev->ct_mode = 1;
|
||||
hdev->hwop.cntlconfig(hdev, CONF_CT_MODE, SET_CT_GAME);
|
||||
}
|
||||
if (CMP_STR("photo")) {
|
||||
hdev->allm_mode = 3;
|
||||
hdev->hwop.cntlconfig(hdev, CONF_ALLM_MODE, SET_ALLM_PHOTO);
|
||||
if (com_str(buf, "2") || com_str(buf, "graphics")) {
|
||||
hdev->ct_mode = 2;
|
||||
hdev->hwop.cntlconfig(hdev, CONF_CT_MODE, SET_CT_GRAPHICS);
|
||||
}
|
||||
if (CMP_STR("cinema")) {
|
||||
hdev->allm_mode = 4;
|
||||
hdev->hwop.cntlconfig(hdev, CONF_ALLM_MODE, SET_ALLM_CINEMA);
|
||||
if (com_str(buf, "3") || com_str(buf, "photo")) {
|
||||
hdev->ct_mode = 3;
|
||||
hdev->hwop.cntlconfig(hdev, CONF_CT_MODE, SET_CT_PHOTO);
|
||||
}
|
||||
if (com_str(buf, "4") || com_str(buf, "cinema")) {
|
||||
hdev->ct_mode = 4;
|
||||
hdev->hwop.cntlconfig(hdev, CONF_CT_MODE, SET_CT_CINEMA);
|
||||
}
|
||||
|
||||
return count;
|
||||
@@ -3884,7 +3933,11 @@ static DEVICE_ATTR(hdr_cap, 0444, show_hdr_cap, NULL);
|
||||
static DEVICE_ATTR(dv_cap, 0444, show_dv_cap, NULL);
|
||||
static DEVICE_ATTR(dc_cap, 0444, show_dc_cap, NULL);
|
||||
static DEVICE_ATTR(valid_mode, 0664, show_valid_mode, store_valid_mode);
|
||||
static DEVICE_ATTR(allm_cap, 0444, show_allm_cap, NULL);
|
||||
static DEVICE_ATTR(allm_mode, 0664, show_allm_mode, store_allm_mode);
|
||||
static DEVICE_ATTR(contenttype_cap, 0444, show_contenttype_cap, NULL);
|
||||
static DEVICE_ATTR(contenttype_mode, 0664,
|
||||
show_contenttype_mode, store_contenttype_mode);
|
||||
static DEVICE_ATTR(aud_ch, 0664, show_aud_ch, store_aud_ch);
|
||||
static DEVICE_ATTR(avmute, 0664, show_avmute, store_avmute);
|
||||
static DEVICE_ATTR(swap, 0644, show_swap, store_swap);
|
||||
@@ -5136,7 +5189,10 @@ static int amhdmitx_probe(struct platform_device *pdev)
|
||||
ret = device_create_file(dev, &dev_attr_support_3d);
|
||||
ret = device_create_file(dev, &dev_attr_dc_cap);
|
||||
ret = device_create_file(dev, &dev_attr_valid_mode);
|
||||
ret = device_create_file(dev, &dev_attr_allm_cap);
|
||||
ret = device_create_file(dev, &dev_attr_allm_mode);
|
||||
ret = device_create_file(dev, &dev_attr_contenttype_cap);
|
||||
ret = device_create_file(dev, &dev_attr_contenttype_mode);
|
||||
|
||||
#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND
|
||||
if (suspend_hdmiphy)
|
||||
@@ -5209,7 +5265,10 @@ static int amhdmitx_remove(struct platform_device *pdev)
|
||||
device_remove_file(dev, &dev_attr_dv_cap);
|
||||
device_remove_file(dev, &dev_attr_dc_cap);
|
||||
device_remove_file(dev, &dev_attr_valid_mode);
|
||||
device_remove_file(dev, &dev_attr_allm_cap);
|
||||
device_remove_file(dev, &dev_attr_allm_mode);
|
||||
device_remove_file(dev, &dev_attr_contenttype_cap);
|
||||
device_remove_file(dev, &dev_attr_contenttype_mode);
|
||||
device_remove_file(dev, &dev_attr_hpd_state);
|
||||
device_remove_file(dev, &dev_attr_rhpd_state);
|
||||
device_remove_file(dev, &dev_attr_max_exceed);
|
||||
|
||||
@@ -995,27 +995,13 @@ int hdmitx_set_display(struct hdmitx_dev *hdev, enum hdmi_vic VideoCode)
|
||||
else
|
||||
;
|
||||
|
||||
switch (hdev->rxcap.allm ? hdev->allm_mode : 0) {
|
||||
case 1: /* game */
|
||||
if (hdev->allm_mode) {
|
||||
hdmitx_construct_vsif(hdev, VT_ALLM, 1, NULL);
|
||||
hdev->hwop.cntlconfig(hdev, CONF_ALLM_MODE,
|
||||
SET_ALLM_GAME);
|
||||
break;
|
||||
case 2: /* graphics */
|
||||
hdev->hwop.cntlconfig(hdev, CONF_ALLM_MODE,
|
||||
SET_ALLM_GRAPHICS);
|
||||
break;
|
||||
case 3: /* photo */
|
||||
hdev->hwop.cntlconfig(hdev, CONF_ALLM_MODE,
|
||||
SET_ALLM_PHOTO);
|
||||
break;
|
||||
case 4: /* cinema */
|
||||
hdev->hwop.cntlconfig(hdev, CONF_ALLM_MODE,
|
||||
SET_ALLM_CINEMA);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
hdev->hwop.cntlconfig(hdev, CONF_CT_MODE,
|
||||
SET_CT_OFF);
|
||||
}
|
||||
hdev->hwop.cntlconfig(hdev, CONF_CT_MODE,
|
||||
hdev->ct_mode);
|
||||
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
@@ -5168,26 +5168,26 @@ static int hdmitx_cntl_config(struct hdmitx_dev *hdev, unsigned int cmd,
|
||||
case CONF_AVI_YQ01:
|
||||
hdmitx_set_reg_bits(HDMITX_DWC_FC_AVICONF3, argv, 2, 2);
|
||||
break;
|
||||
case CONF_ALLM_MODE:
|
||||
if (argv == CLEAR_ALLM_MODE) {
|
||||
case CONF_CT_MODE:
|
||||
if (argv == SET_CT_OFF) {
|
||||
hdmitx_set_reg_bits(HDMITX_DWC_FC_AVICONF2, 0, 7, 1);
|
||||
hdmitx_set_reg_bits(HDMITX_DWC_FC_AVICONF3, 0, 0, 2);
|
||||
break;
|
||||
}
|
||||
if (argv == GET_ALLM_MODE) {
|
||||
if (hdmitx_rd_reg(HDMITX_DWC_FC_AVICONF2) & (1 << 7))
|
||||
ret = hdmitx_rd_reg(HDMITX_DWC_FC_AVICONF3) & 3;
|
||||
else
|
||||
ret = -1;
|
||||
break;
|
||||
if (argv == SET_CT_GAME) {
|
||||
hdmitx_set_reg_bits(HDMITX_DWC_FC_AVICONF2, 1, 7, 1);
|
||||
hdmitx_set_reg_bits(HDMITX_DWC_FC_AVICONF3, 3, 0, 2);
|
||||
}
|
||||
/* set ALLM mode */
|
||||
hdmitx_set_reg_bits(HDMITX_DWC_FC_AVICONF2, 1, 7, 1);
|
||||
hdmitx_set_reg_bits(HDMITX_DWC_FC_AVICONF3, argv & 3, 0, 2);
|
||||
if (argv == SET_ALLM_PHOTO) {
|
||||
// TODO
|
||||
// Extended colorimetry field may be
|
||||
// sYcc601, AdobeYcc601 or AdobeRGB
|
||||
if (argv == SET_CT_GRAPHICS) {
|
||||
hdmitx_set_reg_bits(HDMITX_DWC_FC_AVICONF2, 1, 7, 1);
|
||||
hdmitx_set_reg_bits(HDMITX_DWC_FC_AVICONF3, 0, 0, 2);
|
||||
}
|
||||
if (argv == SET_CT_PHOTO) {
|
||||
hdmitx_set_reg_bits(HDMITX_DWC_FC_AVICONF2, 1, 7, 1);
|
||||
hdmitx_set_reg_bits(HDMITX_DWC_FC_AVICONF3, 1, 0, 2);
|
||||
}
|
||||
if (argv == SET_CT_CINEMA) {
|
||||
hdmitx_set_reg_bits(HDMITX_DWC_FC_AVICONF2, 1, 7, 1);
|
||||
hdmitx_set_reg_bits(HDMITX_DWC_FC_AVICONF3, 2, 0, 2);
|
||||
}
|
||||
break;
|
||||
case CONF_EMP_NUMBER:
|
||||
|
||||
@@ -116,6 +116,10 @@ struct rx_cap {
|
||||
unsigned int max_frl_rate:4;
|
||||
unsigned int fpap_start_loc:1;
|
||||
unsigned int allm:1;
|
||||
unsigned int cnc0:1; /* Graphics */
|
||||
unsigned int cnc1:1; /* Photo */
|
||||
unsigned int cnc2:1; /* Cinema */
|
||||
unsigned int cnc3:1; /* Game */
|
||||
unsigned int mdelta:1;
|
||||
unsigned int fva:1;
|
||||
unsigned int hdr_sup_eotf_sdr:1;
|
||||
@@ -447,8 +451,8 @@ struct hdmitx_dev {
|
||||
unsigned int cedst_policy;
|
||||
struct ced_cnt ced_cnt;
|
||||
struct scdc_locked_st chlocked_st;
|
||||
/* allm_mode: 1/game, 2/graphcis, 3/photo, 4/cinema */
|
||||
unsigned int allm_mode;
|
||||
unsigned int allm_mode; /* allm_mode: 1/on 0/off */
|
||||
unsigned int ct_mode; /* 0/off 1/game, 2/graphcis, 3/photo, 4/cinema */
|
||||
unsigned int sspll;
|
||||
/* configure for I2S: 8ch in, 2ch out */
|
||||
/* 0: default setting 1:ch0/1 2:ch2/3 3:ch4/5 4:ch6/7 */
|
||||
@@ -538,13 +542,12 @@ struct hdmitx_dev {
|
||||
#define YCC_RANGE_LIM 0
|
||||
#define YCC_RANGE_FUL 1
|
||||
#define YCC_RANGE_RSVD 2
|
||||
#define CONF_ALLM_MODE (CMD_CONF_OFFSET + 0X2000 + 0x04)
|
||||
#define SET_ALLM_GRAPHICS 0
|
||||
#define SET_ALLM_PHOTO 1
|
||||
#define SET_ALLM_CINEMA 2
|
||||
#define SET_ALLM_GAME 3
|
||||
#define CLEAR_ALLM_MODE 0xf
|
||||
#define GET_ALLM_MODE 0x10
|
||||
#define CONF_CT_MODE (CMD_CONF_OFFSET + 0X2000 + 0x04)
|
||||
#define SET_CT_OFF 0
|
||||
#define SET_CT_GAME 1
|
||||
#define SET_CT_GRAPHICS 2
|
||||
#define SET_CT_PHOTO 3
|
||||
#define SET_CT_CINEMA 4
|
||||
#define CONF_VIDEO_MUTE_OP (CMD_CONF_OFFSET + 0x1000 + 0x04)
|
||||
#define VIDEO_MUTE 0x1
|
||||
#define VIDEO_UNMUTE 0x2
|
||||
|
||||
Reference in New Issue
Block a user