Files
2026-08-24 10:03:24 +08:00

211 lines
5.3 KiB
C

/* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */
/*
* Copyright (c) 2019 Amlogic, Inc. All rights reserved.
*/
#ifndef __MESON_HDMI_H__
#define __MESON_HDMI_H__
#include "meson_drv.h"
#include <uapi/amlogic/drm/meson_drm.h>
#include <drm/amlogic/meson_hdmi_diag.h>
#include <drm/drm_connector.h>
#include <drm/drm_encoder.h>
#include <drm/amlogic/meson_connector_dev.h>
#include <linux/amlogic/media/vout/hdmitx_common/hdmitx_common.h>
#include <media/cec-notifier.h>
enum {
HDCP_STATE_START = 0,
HDCP_STATE_SUCCESS,
HDCP_STATE_FAIL,
HDCP_STATE_STOP,
HDCP_STATE_DISCONNECT,
};
enum {
MESON_PREF_DV = 0,
MESON_PREF_HDR,
MESON_PREF_SDR,
};
struct hdmitx_color_attr {
enum hdmi_colorspace colorformat;
int bitdepth;
};
struct meson_hdr_static_metadata {
u8 lumi_max;
u8 lumi_min;
u8 lumi_avg;
};
enum meson_color_attr_type {
COLOR_YCBCR420_12BIT = 0,
COLOR_YCBCR420_10BIT,
COLOR_YCBCR420_8BIT,
COLOR_YCBCR444_12BIT,
COLOR_YCBCR444_10BIT,
COLOR_YCBCR444_8BIT,
COLOR_YCBCR422_12BIT,
COLOR_RGB_12BIT,
COLOR_RGB_10BIT,
COLOR_RGB_8BIT,
COLOR_MAX_ATTR,
};
struct am_hdmi_tx {
struct meson_connector base;
struct drm_encoder encoder;
/*drm request content type.*/
int hdcp_request_content_type;
int hdcp_request_content_protection;
/*current hdcp running mode, HDCP_NULL means hdcp disabled.*/
int hdcp_mode;
/*hdcp auth result, HDCP_AUTH_UNKNOWN means havenot finished auth.*/
int hdcp_state;
int hdcp_rx_type;
int hdmitx_on;
int min_vfreq;
int max_vfreq;
/* save sequence_id for drm connecter get raw edid */
u64 sequence_id;
/*TODO: android compatible, remove later*/
bool android_path;
bool recovery_mode;
/*
* HWC enable hdcp flow
* 0: IVCX chip don't need: T7/S5/S6/S7/S7D/S1A
* 1: SNPS chip need: SC2/S4/G12/SM1
*/
struct drm_property *hdcp_user_prop;
struct drm_property *hdcp_topo_prop;
struct drm_property *hdcp_ver_prop;
struct drm_property *hdcp_mode_prop;
/* May be changed by hdr_priority */
struct drm_property *hdr_cap_prop;
/* TV's real hdr capability that not changed by hdr_priority */
struct drm_property *hdr_cap_rx_prop;
struct drm_property *dv_cap_prop;
/* TV's real dv capability that not changed by hdr_priority */
struct drm_property *dv_cap_rx_prop;
struct drm_property *dc_cap_prop;
struct drm_property *contenttype_cap_prop;
struct drm_property *allm_cap_prop;
struct drm_property *allm_prop;
/*amlogic property: force hdmitx update
*colorspace/colordepth from sysfs.
*/
struct drm_property *update_attr_prop;
struct drm_property *avmute_prop;
struct drm_property *ready_prop;
struct drm_property *frac_rate_policy_prop;
/*
* if HDMI plugin even once time, then set 1
* if never hdmi plugin, then keep as 0
*/
struct drm_property *hdmi_used_prop;
/*
* the current HDMI RX device type
* 1 none
* 2 repeater
* 4 sink
*/
struct drm_property *sink_type_prop;
/*
* Whether the current edid is valid
* 0:edid is invalid
* 1:edid is valid
*/
struct drm_property *edid_valid_prop;
/*
* TV VRR Capability
* Range: 0-3
* BIT(0): QMS
* BIT(1): GAME
* Android uses vrr_capable
* Linux uses vrr_capable_type
*/
struct drm_property *vrr_capable_type_prop;
/*
* 0:HDMI
* 1:DVI
*/
struct drm_property *sink_device_type_prop;
struct drm_property *color_space_prop;
struct drm_property *color_depth_prop;
struct drm_property *hdmi_hdr_status_prop;
struct drm_property *hdr_priority_prop;
struct drm_property *type_prop;
int hdmi_type;
struct drm_property *static_meta_prop;
struct drm_property *scan_info_prop;
#ifdef CONFIG_CEC_NOTIFIER
struct cec_notifier *cec_notifier;
#endif
struct meson_connector_dev *hdmitx_dev;
struct hdr_info hdr_info;
struct dv_info dv_info;
/* update content protection property */
struct work_struct hdcp_update_work;
int content_protection;
};
struct am_hdmitx_connector_state {
struct drm_connector_state base;
struct hdmitx_common_state hcs;
/*
* drm hdmitx attr from external modules,
* ONLY used for once, and reset when duplicate.
*/
struct hdmitx_color_attr color_attr_para;
/*HDR Priority: dv,hdr,sdr*/
int pref_hdr_policy;
u32 hdr_priority;
enum hdmi_scan_mode scan_info;
bool update : 1;
bool color_force : 1;
bool avmute : 1;
bool ready : 1;
bool frac_rate_policy : 1;
int allm_mode;
struct drm_property_blob *metadata;
};
#define to_am_hdmitx_connector_state(x) container_of(x, struct am_hdmitx_connector_state, base)
#define meson_connector_to_am_hdmi(x) container_of(x, struct am_hdmi_tx, base)
#define connector_to_am_hdmi(x) \
container_of(connector_to_meson_connector(x), struct am_hdmi_tx, base)
#define encoder_to_am_hdmi(x) container_of(x, struct am_hdmi_tx, encoder)
int meson_hdmitx_dev_bind(struct drm_device *drm,
int type, struct meson_connector_dev *intf);
int meson_hdmitx_dev_unbind(struct drm_device *drm,
int type, struct meson_connector_dev *intf);
void convert_attrstr(char *attr_str, struct hdmitx_color_attr *attr_param);
int am_meson_mode_testattr_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int am_meson_get_vrr_range_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int am_meson_get_hdmitx_diag_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
void hdmitx_diag_init(struct hdmitx_common *tx_comm);
struct hdmitx_common *meson_get_hdmitx_common(struct drm_connector *connector);
#endif