提交 831a8d5e 编写于 作者: S Shawn Guo

drm: zte: move struct vou_inf into zx_vou driver

Although data in struct vou_inf is defined per output device, it doesn't
belong to the device itself but VOU control module.  All these data can
just be defined in VOU driver, and output device driver only needs to
invoke VOU driver function with device ID to enable/disable specific
output device.
Signed-off-by: NShawn Guo <shawn.guo@linaro.org>
Reviewed-by: NSean Paul <seanpaul@chromium.org>
上级 6848af2d
...@@ -56,13 +56,6 @@ struct zx_hdmi { ...@@ -56,13 +56,6 @@ struct zx_hdmi {
#define to_zx_hdmi(x) container_of(x, struct zx_hdmi, x) #define to_zx_hdmi(x) container_of(x, struct zx_hdmi, x)
static const struct vou_inf vou_inf_hdmi = {
.id = VOU_HDMI,
.data_sel = VOU_YUV444,
.clocks_en_bits = BIT(24) | BIT(18) | BIT(6),
.clocks_sel_bits = BIT(13) | BIT(2),
};
static inline u8 hdmi_readb(struct zx_hdmi *hdmi, u16 offset) static inline u8 hdmi_readb(struct zx_hdmi *hdmi, u16 offset)
{ {
return readl_relaxed(hdmi->mmio + offset * 4); return readl_relaxed(hdmi->mmio + offset * 4);
...@@ -241,14 +234,14 @@ static void zx_hdmi_encoder_enable(struct drm_encoder *encoder) ...@@ -241,14 +234,14 @@ static void zx_hdmi_encoder_enable(struct drm_encoder *encoder)
zx_hdmi_hw_enable(hdmi); zx_hdmi_hw_enable(hdmi);
vou_inf_enable(hdmi->inf, encoder->crtc); vou_inf_enable(VOU_HDMI, encoder->crtc);
} }
static void zx_hdmi_encoder_disable(struct drm_encoder *encoder) static void zx_hdmi_encoder_disable(struct drm_encoder *encoder)
{ {
struct zx_hdmi *hdmi = to_zx_hdmi(encoder); struct zx_hdmi *hdmi = to_zx_hdmi(encoder);
vou_inf_disable(hdmi->inf, encoder->crtc); vou_inf_disable(VOU_HDMI, encoder->crtc);
zx_hdmi_hw_disable(hdmi); zx_hdmi_hw_disable(hdmi);
...@@ -662,7 +655,6 @@ static int zx_hdmi_bind(struct device *dev, struct device *master, void *data) ...@@ -662,7 +655,6 @@ static int zx_hdmi_bind(struct device *dev, struct device *master, void *data)
hdmi->dev = dev; hdmi->dev = dev;
hdmi->drm = drm; hdmi->drm = drm;
hdmi->inf = &vou_inf_hdmi;
dev_set_drvdata(dev, hdmi); dev_set_drvdata(dev, hdmi);
......
...@@ -158,6 +158,28 @@ struct zx_vou_hw { ...@@ -158,6 +158,28 @@ struct zx_vou_hw {
struct zx_crtc *aux_crtc; struct zx_crtc *aux_crtc;
}; };
enum vou_inf_data_sel {
VOU_YUV444 = 0,
VOU_RGB_101010 = 1,
VOU_RGB_888 = 2,
VOU_RGB_666 = 3,
};
struct vou_inf {
enum vou_inf_id id;
enum vou_inf_data_sel data_sel;
u32 clocks_en_bits;
u32 clocks_sel_bits;
};
static struct vou_inf vou_infs[] = {
[VOU_HDMI] = {
.data_sel = VOU_YUV444,
.clocks_en_bits = BIT(24) | BIT(18) | BIT(6),
.clocks_sel_bits = BIT(13) | BIT(2),
},
};
static inline struct zx_vou_hw *crtc_to_vou(struct drm_crtc *crtc) static inline struct zx_vou_hw *crtc_to_vou(struct drm_crtc *crtc)
{ {
struct zx_crtc *zcrtc = to_zx_crtc(crtc); struct zx_crtc *zcrtc = to_zx_crtc(crtc);
...@@ -174,20 +196,21 @@ void vou_inf_hdmi_audio_sel(struct drm_crtc *crtc, ...@@ -174,20 +196,21 @@ void vou_inf_hdmi_audio_sel(struct drm_crtc *crtc,
zx_writel_mask(vou->vouctl + VOU_INF_HDMI_CTRL, VOU_HDMI_AUD_MASK, aud); zx_writel_mask(vou->vouctl + VOU_INF_HDMI_CTRL, VOU_HDMI_AUD_MASK, aud);
} }
void vou_inf_enable(const struct vou_inf *inf, struct drm_crtc *crtc) void vou_inf_enable(enum vou_inf_id id, struct drm_crtc *crtc)
{ {
struct zx_crtc *zcrtc = to_zx_crtc(crtc); struct zx_crtc *zcrtc = to_zx_crtc(crtc);
struct zx_vou_hw *vou = zcrtc->vou; struct zx_vou_hw *vou = zcrtc->vou;
struct vou_inf *inf = &vou_infs[id];
bool is_main = zcrtc->chn_type == VOU_CHN_MAIN; bool is_main = zcrtc->chn_type == VOU_CHN_MAIN;
u32 data_sel_shift = inf->id << 1; u32 data_sel_shift = id << 1;
/* Select data format */ /* Select data format */
zx_writel_mask(vou->vouctl + VOU_INF_DATA_SEL, 0x3 << data_sel_shift, zx_writel_mask(vou->vouctl + VOU_INF_DATA_SEL, 0x3 << data_sel_shift,
inf->data_sel << data_sel_shift); inf->data_sel << data_sel_shift);
/* Select channel */ /* Select channel */
zx_writel_mask(vou->vouctl + VOU_INF_CH_SEL, 0x1 << inf->id, zx_writel_mask(vou->vouctl + VOU_INF_CH_SEL, 0x1 << id,
zcrtc->chn_type << inf->id); zcrtc->chn_type << id);
/* Select interface clocks */ /* Select interface clocks */
zx_writel_mask(vou->vouctl + VOU_CLK_SEL, inf->clocks_sel_bits, zx_writel_mask(vou->vouctl + VOU_CLK_SEL, inf->clocks_sel_bits,
...@@ -198,15 +221,16 @@ void vou_inf_enable(const struct vou_inf *inf, struct drm_crtc *crtc) ...@@ -198,15 +221,16 @@ void vou_inf_enable(const struct vou_inf *inf, struct drm_crtc *crtc)
inf->clocks_en_bits); inf->clocks_en_bits);
/* Enable the device */ /* Enable the device */
zx_writel_mask(vou->vouctl + VOU_INF_EN, 1 << inf->id, 1 << inf->id); zx_writel_mask(vou->vouctl + VOU_INF_EN, 1 << id, 1 << id);
} }
void vou_inf_disable(const struct vou_inf *inf, struct drm_crtc *crtc) void vou_inf_disable(enum vou_inf_id id, struct drm_crtc *crtc)
{ {
struct zx_vou_hw *vou = crtc_to_vou(crtc); struct zx_vou_hw *vou = crtc_to_vou(crtc);
struct vou_inf *inf = &vou_infs[id];
/* Disable the device */ /* Disable the device */
zx_writel_mask(vou->vouctl + VOU_INF_EN, 1 << inf->id, 0); zx_writel_mask(vou->vouctl + VOU_INF_EN, 1 << id, 0);
/* Disable interface clocks */ /* Disable interface clocks */
zx_writel_mask(vou->vouctl + VOU_CLK_EN, inf->clocks_en_bits, 0); zx_writel_mask(vou->vouctl + VOU_CLK_EN, inf->clocks_en_bits, 0);
......
...@@ -23,13 +23,6 @@ enum vou_inf_id { ...@@ -23,13 +23,6 @@ enum vou_inf_id {
VOU_VGA = 5, VOU_VGA = 5,
}; };
enum vou_inf_data_sel {
VOU_YUV444 = 0,
VOU_RGB_101010 = 1,
VOU_RGB_888 = 2,
VOU_RGB_666 = 3,
};
enum vou_inf_hdmi_audio { enum vou_inf_hdmi_audio {
VOU_HDMI_AUD_SPDIF = BIT(0), VOU_HDMI_AUD_SPDIF = BIT(0),
VOU_HDMI_AUD_I2S = BIT(1), VOU_HDMI_AUD_I2S = BIT(1),
...@@ -38,17 +31,10 @@ enum vou_inf_hdmi_audio { ...@@ -38,17 +31,10 @@ enum vou_inf_hdmi_audio {
VOU_HDMI_AUD_PARALLEL = BIT(4), VOU_HDMI_AUD_PARALLEL = BIT(4),
}; };
struct vou_inf {
enum vou_inf_id id;
enum vou_inf_data_sel data_sel;
u32 clocks_en_bits;
u32 clocks_sel_bits;
};
void vou_inf_hdmi_audio_sel(struct drm_crtc *crtc, void vou_inf_hdmi_audio_sel(struct drm_crtc *crtc,
enum vou_inf_hdmi_audio aud); enum vou_inf_hdmi_audio aud);
void vou_inf_enable(const struct vou_inf *inf, struct drm_crtc *crtc); void vou_inf_enable(enum vou_inf_id id, struct drm_crtc *crtc);
void vou_inf_disable(const struct vou_inf *inf, struct drm_crtc *crtc); void vou_inf_disable(enum vou_inf_id id, struct drm_crtc *crtc);
int zx_vou_enable_vblank(struct drm_device *drm, unsigned int pipe); int zx_vou_enable_vblank(struct drm_device *drm, unsigned int pipe);
void zx_vou_disable_vblank(struct drm_device *drm, unsigned int pipe); void zx_vou_disable_vblank(struct drm_device *drm, unsigned int pipe);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册