202 lines
4.9 KiB
C
202 lines
4.9 KiB
C
/* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */
|
|
/*
|
|
* Copyright (c) 2019 Amlogic, Inc. All rights reserved.
|
|
*/
|
|
|
|
#ifndef __MESON_CRTC_H
|
|
#define __MESON_CRTC_H
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/mutex.h>
|
|
#include <drm/drmP.h>
|
|
#include <drm/drm_plane.h>
|
|
#include <drm/drm_atomic.h>
|
|
#include <drm/drm_atomic_helper.h>
|
|
#include "meson_vpu.h"
|
|
#include "meson_drv.h"
|
|
#include "meson_fb.h"
|
|
#include "meson_plane.h"
|
|
|
|
enum {
|
|
MESON_HDR_POLICY_FOLLOW_SINK = 0,
|
|
MESON_HDR_POLICY_FOLLOW_SOURCE,
|
|
MESON_HDR_POLICY_FOLLOW_FORCE_MODE,
|
|
};
|
|
|
|
enum {
|
|
VBLANK_STEP_1 = 1,
|
|
VBLANK_STEP_2 = 2,
|
|
};
|
|
|
|
enum {
|
|
HDMI_EOTF_MESON_DOLBYVISION = (HDMI_EOTF_BT_2100_HLG + 0xf),
|
|
HDMI_EOTF_MESON_DOLBYVISION_LL,
|
|
};
|
|
|
|
enum {
|
|
RGBA_8888 = 0,
|
|
RGBX_8888,
|
|
RGB_888,
|
|
RGB_565,
|
|
BGRA_8888,
|
|
};
|
|
|
|
enum {
|
|
YCBCR_422_SP = 0,
|
|
YCBCR_422_I,
|
|
YCRCB_420_SP,
|
|
};
|
|
|
|
struct am_meson_crtc_present_fence {
|
|
u32 fd;
|
|
struct dma_fence *fence;
|
|
struct sync_file *sync_file;
|
|
};
|
|
|
|
struct am_meson_crtc_state {
|
|
struct drm_crtc_state base;
|
|
|
|
/*vout mode indicate connector type*/
|
|
enum vmode_e vmode;
|
|
enum vmode_e preset_vmode;
|
|
|
|
int uboot_mode_init;
|
|
/*policy update by y property*/
|
|
u8 crtc_hdr_process_policy; /*follow sink or follow source*/
|
|
/*only used to indicate if dv ll mode output now.*/
|
|
u8 crtc_eotf_type;
|
|
/*dv core enabled, control by userspace not driver*/
|
|
bool crtc_dv_enable;
|
|
bool dv_mode;
|
|
/*hdr core enabled, always on if soc support hdr.*/
|
|
bool crtc_hdr_enable;
|
|
/* force output by property */
|
|
u8 force_output_type;
|
|
/*crtc background*/
|
|
bool crtc_bgcolor_flag;
|
|
u64 crtc_bgcolor;
|
|
/*basic refresh rate*/
|
|
u32 brr;
|
|
u32 valid_brr;
|
|
u32 vrr_type;
|
|
u32 game_rate;
|
|
|
|
/* target vblank cnt */
|
|
u64 target_vblank_cnt;
|
|
|
|
/*brr mode string*/
|
|
char brr_mode[DRM_DISPLAY_MODE_LEN];
|
|
/*for nonblock commit, one commit do not wait flip done for preceding commits*/
|
|
bool nonblock_by_vblank;
|
|
|
|
int prev_vrefresh;
|
|
int prev_height;
|
|
int hdr_conversion_ctrl;
|
|
bool attr_changed;
|
|
bool brr_update;
|
|
|
|
bool seamless;
|
|
unsigned int frac;
|
|
unsigned int viu_mux;
|
|
/* when set val to true, the signal outfence is delayed by one vsync */
|
|
bool outfence_ctrl;
|
|
};
|
|
|
|
struct am_meson_crtc {
|
|
struct drm_crtc base;
|
|
struct device *dev;
|
|
struct drm_device *drm_dev;
|
|
struct meson_drm *priv;
|
|
|
|
unsigned int irq;
|
|
int crtc_index;
|
|
int vout_index;
|
|
struct drm_pending_vblank_event *event;
|
|
struct meson_vpu_pipeline *pipeline;
|
|
|
|
struct drm_property *hdr_policy;
|
|
struct drm_property *dv_enable_property;
|
|
struct drm_property *outfence_ctrl_property;
|
|
struct drm_property *brr_update_property;
|
|
struct drm_property *dv_mode_property;
|
|
struct drm_property *bgcolor_property;
|
|
struct drm_property *video_pixelformat_property;
|
|
struct drm_property *vpu_clk_property;
|
|
struct drm_property *osd_pixelformat_property;
|
|
struct drm_property *hdr_conversion_ctrl_property;
|
|
struct drm_property *hdr_conversion_cap_property;
|
|
struct drm_property *force_output;
|
|
struct drm_property *drm_policy_property;
|
|
struct drm_property *nonblock_by_vblank_property;
|
|
/*vpu pipeline dolby core cap*/
|
|
struct drm_property *dv_support_info;
|
|
|
|
struct drm_property *crtc_max_out_property;
|
|
|
|
/* game vrr property */
|
|
struct drm_property *vrr_type_property;
|
|
struct drm_property *game_rate_property;
|
|
|
|
/* target vblank */
|
|
struct drm_property *target_vblk_property;
|
|
|
|
/*debug*/
|
|
int dump_enable;
|
|
int blank_enable;
|
|
int target_vblank_disable;
|
|
int dump_counts;
|
|
int dump_index;
|
|
char osddump_path[64];
|
|
bool rdma_table_enable;
|
|
|
|
/*present fence*/
|
|
struct am_meson_crtc_present_fence present_fence;
|
|
|
|
/*commit*/
|
|
struct mutex commit_mutex;
|
|
atomic_t commit_num;
|
|
|
|
int vpp_crc_enable;
|
|
/*forced to detect crc several times after bootup.*/
|
|
int force_crc_chk;
|
|
/*funcs*/
|
|
int (*get_scanout_position)(struct am_meson_crtc *crtc,
|
|
bool in_vblank_irq, int *vpos, int *hpos,
|
|
ktime_t *stime, ktime_t *etime,
|
|
const struct drm_display_mode *mode);
|
|
|
|
/* spinlock to protect the fences in the fence_context */
|
|
spinlock_t present_fence_lock;
|
|
u64 present_context;
|
|
u64 present_seqno;
|
|
};
|
|
|
|
#define to_am_meson_crtc(x) container_of(x, \
|
|
struct am_meson_crtc, base)
|
|
#define to_am_meson_crtc_state(x) container_of(x, \
|
|
struct am_meson_crtc_state, base)
|
|
|
|
struct am_meson_crtc *meson_crtc_bind(struct meson_drm *priv,
|
|
int idx);
|
|
int meson_crtc_creat_present_fence_ioctl(struct drm_device *dev,
|
|
void *data, struct drm_file *file_priv);
|
|
#ifndef CONFIG_AMLOGIC_ZAPPER_CUT
|
|
int am_meson_lcd_get_vrr_range(struct drm_connector *connector,
|
|
struct drm_vrr_mode_group *groups, int max_group);
|
|
int am_meson_eDP_get_vrr_range(struct drm_connector *connector,
|
|
struct drm_vrr_mode_group *groups, int max_group);
|
|
#endif
|
|
|
|
#if !defined(CONFIG_AMLOGIC_DRM_CUT_HDMI) || !defined(CONFIG_AMLOGIC_DRM_CUT_HDMI_MODERN)
|
|
int am_meson_hdmi_get_vrr_range(struct drm_device *dev,
|
|
void *data, struct drm_file *file_priv);
|
|
int am_meson_hdmi_get_hdmitx_diag(struct drm_device *dev,
|
|
void *data, struct drm_file *file_priv);
|
|
#endif
|
|
|
|
#ifdef CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_VECM
|
|
void set_hdr_policy(int policy);
|
|
int get_hdr_policy(void);
|
|
#endif
|
|
#endif
|