rmk's Dove DRM/TDA19988 Cubox driver
Subsystems (3)
cover rmk's Dove DRM/TDA19988 Cubox driver
What follows is my DRM driver for Dove, which I've been working on with the Solid-run Cubox, which only offers HDMI output via the TDA19988 chip.
Not everything is finished off perfectly in this driver; there's quite a number of ragged edges (particularly with page flipping, which is completely untested.)
I have most of the Xorg driver complete - none of the DRI interfaces checked yet (partly because that involves quite an amount of work with Mesa).
However, graphics, video overlay, interlacing, accelerated GPU via the original vivante support all works through this driver, with this driver providing the X pixmaps.
RFC 1/8 DRM: Add Dove DRM driver
This patch adds support for the pair of LCD controllers on the Marvell Armada 510 (aka Dove) SoCs. This driver supports:
- multiple contiguous scanout buffers for video and graphics
- shm backed cacheable buffer objects for X pixmaps for Vivante GPU acceleration
- dual lcd0 and lcd1 crt operation
- video overlay on each LCD crt
- page flipping of the main scanout buffers
Included in this commit is the core driver with no output support; output support is platform and encoder driver dependent.
--- drivers/gpu/drm/Kconfig | 2 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/dove/Kconfig | 22 + drivers/gpu/drm/dove/Makefile | 7 + drivers/gpu/drm/dove/dove_crtc.c | 917 +++++++++++++++++++++++++++++++++++ drivers/gpu/drm/dove/dove_crtc.h | 87 ++++ drivers/gpu/drm/dove/dove_debugfs.c | 186 +++++++ drivers/gpu/drm/dove/dove_drm.h | 64 +++ drivers/gpu/drm/dove/dove_drv.c | 323 ++++++++++++ drivers/gpu/drm/dove/dove_fb.c | 156 ++++++ drivers/gpu/drm/dove/dove_fb.h | 21 + drivers/gpu/drm/dove/dove_fbdev.c | 210 ++++++++ drivers/gpu/drm/dove/dove_gem.c | 420 ++++++++++++++++ drivers/gpu/drm/dove/dove_gem.h | 41 ++ drivers/gpu/drm/dove/dove_hw.h | 283 +++++++++++ drivers/gpu/drm/dove/dove_ioctl.h | 128 +++++ drivers/gpu/drm/dove/dove_ioctlP.h | 22 + drivers/gpu/drm/dove/dove_output.c | 124 +++++ drivers/gpu/drm/dove/dove_output.h | 26 + drivers/gpu/drm/dove/dove_overlay.c | 514 ++++++++++++++++++++ drivers/gpu/drm/dove/drm_helper.h | 31 ++ 21 files changed, 3585 insertions(+), 0 deletions(-) create mode 100644 drivers/gpu/drm/dove/Kconfig create mode 100644 drivers/gpu/drm/dove/Makefile create mode 100644 drivers/gpu/drm/dove/dove_crtc.c create mode 100644 drivers/gpu/drm/dove/dove_crtc.h create mode 100644 drivers/gpu/drm/dove/dove_debugfs.c create mode 100644 drivers/gpu/drm/dove/dove_drm.h create mode 100644 drivers/gpu/drm/dove/dove_drv.c create mode 100644 drivers/gpu/drm/dove/dove_fb.c create mode 100644 drivers/gpu/drm/dove/dove_fb.h create mode 100644 drivers/gpu/drm/dove/dove_fbdev.c create mode 100644 drivers/gpu/drm/dove/dove_gem.c create mode 100644 drivers/gpu/drm/dove/dove_gem.h create mode 100644 drivers/gpu/drm/dove/dove_hw.h create mode 100644 drivers/gpu/drm/dove/dove_ioctl.h create mode 100644 drivers/gpu/drm/dove/dove_ioctlP.h create mode 100644 drivers/gpu/drm/dove/dove_output.c create mode 100644 drivers/gpu/drm/dove/dove_output.h create mode 100644 drivers/gpu/drm/dove/dove_overlay.c create mode 100644 drivers/gpu/drm/dove/drm_helper.h
drivers/gpu/drm/Kconfig +2 -0
@@ -213,6 +213,8 @@ source "drivers/gpu/drm/mgag200/Kconfig" source "drivers/gpu/drm/cirrus/Kconfig" +source "drivers/gpu/drm/dove/Kconfig" + source "drivers/gpu/drm/shmobile/Kconfig" source "drivers/gpu/drm/tegra/Kconfig"
drivers/gpu/drm/Makefile +1 -0
@@ -48,6 +48,7 @@ obj-$(CONFIG_DRM_EXYNOS) +=exynos/ obj-$(CONFIG_DRM_GMA500) += gma500/ obj-$(CONFIG_DRM_UDL) += udl/ obj-$(CONFIG_DRM_AST) += ast/ +obj-$(CONFIG_DRM_DOVE) += dove/ obj-$(CONFIG_DRM_SHMOBILE) +=shmobile/ obj-$(CONFIG_DRM_TEGRA) += tegra/ obj-$(CONFIG_DRM_OMAP) += omapdrm/
drivers/gpu/drm/dove/Kconfig new file +22 -0
@@ -0,0 +1,22 @@ +config DRM_DOVE + tristate "DRM support for Marvell Dove" + depends on DRM && HAVE_CLK + select FB_CFB_FILLRECT + select FB_CFB_COPYAREA + select FB_CFB_IMAGEBLIT + select DRM_KMS_HELPER + help + Support the "LCD" controllers found on the Marvell Armada 510 + Dove devices. There are two controllers on the device, each + controller supports graphics and video overlays. + + This driver provides no built-in acceleration; acceleration is + performed by other IP found on the SoC. This driver provides + kernel mode setting and buffer management to userspace. + +if DRM_DOVE != n + +config DRM_DOVE_CURSOR + bool "Enable Dove DRM hardware cursor support" + +endif
drivers/gpu/drm/dove/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +ccflags-y := -Iinclude/drm + +dove-y := dove_crtc.o dove_drv.o dove_fb.o dove_fbdev.o \ + dove_gem.o dove_output.o dove_overlay.o +dove-$(CONFIG_DEBUG_FS) += dove_debugfs.o + +obj-$(CONFIG_DRM_DOVE) := dove.o
drivers/gpu/drm/dove/dove_crtc.c new file +917 -0
917 lines not on this page · raw message
drivers/gpu/drm/dove/dove_crtc.h new file +87 -0
87 lines not on this page · raw message
drivers/gpu/drm/dove/dove_debugfs.c new file +186 -0
186 lines not on this page · raw message
drivers/gpu/drm/dove/dove_drm.h new file +64 -0
64 lines not on this page · raw message
drivers/gpu/drm/dove/dove_drv.c new file +323 -0
323 lines not on this page · raw message
drivers/gpu/drm/dove/dove_fb.c new file +156 -0
156 lines not on this page · raw message
drivers/gpu/drm/dove/dove_fb.h new file +21 -0
@@ -0,0 +1,21 @@ +/* +* Copyright (C) 2012 Russell King +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ +#ifndef DOVE_FB_H +#define DOVE_FB_H + +struct dove_framebuffer { +struct drm_framebuffer fb; +struct dove_gem_object *obj; +}; +#define drm_fb_to_dove_fb (dfb) container_of(dfb, struct dove_framebuffer, fb) +#define drm_fb_obj (fb) drm_fb_to_dove_fb(fb)->obj + +int dove_framebuffer_create (struct drm_device *,struct dove_framebuffer **, +struct drm_mode_fb_cmd2 *,struct dove_gem_object *); + +#endif
drivers/gpu/drm/dove/dove_fbdev.c new file +210 -0
210 lines not on this page · raw message
drivers/gpu/drm/dove/dove_gem.c new file +420 -0
420 lines not on this page · raw message
drivers/gpu/drm/dove/dove_gem.h new file +41 -0
41 lines not on this page · raw message
drivers/gpu/drm/dove/dove_hw.h new file +283 -0
283 lines not on this page · raw message
drivers/gpu/drm/dove/dove_ioctl.h new file +128 -0
128 lines not on this page · raw message
drivers/gpu/drm/dove/dove_ioctlP.h new file +22 -0
@@ -0,0 +1,22 @@ +/* +* Copyright (C) 2012 Russell King +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ +#ifndef DOVE_IOCTLP_H +#define DOVE_IOCTLP_H + +#define DOVE_IOCTL_PROTO (name)\ +extern int dove_##name##_ioctl(struct drm_device *, void *, struct drm_file *) + +DOVE_IOCTL_PROTO (gem_create); +DOVE_IOCTL_PROTO (gem_create_phys); +DOVE_IOCTL_PROTO (gem_mmap); +DOVE_IOCTL_PROTO (gem_prop); +DOVE_IOCTL_PROTO (gem_pwrite); +DOVE_IOCTL_PROTO (overlay_put_image); +DOVE_IOCTL_PROTO (overlay_attrs); + +#endif
drivers/gpu/drm/dove/dove_output.c new file +124 -0
98 lines not on this page · raw message
drivers/gpu/drm/dove/dove_output.h new file +26 -0
Lines of this file are not shown. View the raw message.
drivers/gpu/drm/dove/dove_overlay.c new file +514 -0
514 lines not on this page · raw message
drivers/gpu/drm/dove/drm_helper.h new file +31 -0
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.4.4
Part of the diff is not shown here. View the raw message.
RFC 2/8 drm/i2c: nxp-tda998x: fix EDID reading on TDA19988 devices
In reply to Russell King - ARM LinuxTDA19988 devices need their RAM enabled in order to read EDID information. Add support for this.
--- drivers/gpu/drm/i2c/tda998x_drv.c | 14 +++++++++++++- 1 files changed, 13 insertions(+), 1 deletions(-)
drivers/gpu/drm/i2c/tda998x_drv.c +13 -1
@@ -229,6 +229,8 @@ struct tda998x_priv {/* Page 12h: HDCP and OTP */ #define REG_TX3 REG(0x12, 0x9a)/* read/write */ +#define REG_TX4 REG(0x12, 0x9b)/* read/write */ +# define TX4_PD_RAM (1 << 1)#define REG_TX33 REG(0x12, 0xb8)/* read/write */ # define TX33_HDMI (1 << 1)
@@ -673,6 +675,7 @@ read_edid_block(struct drm_encoder *encoder, uint8_t *buf, int blk)static uint8_t *do_get_edid (struct drm_encoder *encoder) { +struct tda998x_priv *priv =to_tda998x_priv (encoder);int j =0 , valid_extensions =0 ;uint8_t *block, *new;bool print_bad_edid = drm_debug &DRM_UT_KMS ;
@@ -680,6 +683,9 @@ do_get_edid(struct drm_encoder *encoder)if ((block =kmalloc (EDID_LENGTH ,GFP_KERNEL )) ==NULL )return NULL ; +if (priv->rev ==TDA19988 ) +reg_clear (encoder,REG_TX4 ,TX4_PD_RAM ); +/* base block fetch */ if (read_edid_block (encoder, block,0 )) goto fail;
@@ -689,7 +695,7 @@ do_get_edid(struct drm_encoder *encoder)/* if there's no extensions, we're done */ if (block[0x7e ] ==0 ) -return block; + goto done; new =krealloc (block, (block[0x7e ] +1 ) *EDID_LENGTH ,GFP_KERNEL );if (!new)
@@ -716,9 +722,15 @@ do_get_edid(struct drm_encoder *encoder) block = new; } +done: +if (priv->rev ==TDA19988 ) +reg_set (encoder,REG_TX4 ,TX4_PD_RAM ); +return block; fail: +if (priv->rev ==TDA19988 ) +reg_set (encoder,REG_TX4 ,TX4_PD_RAM );dev_warn (encoder->dev->dev,"failed to read EDID\n" );kfree (block);return NULL ;
Signature · 1 line
1.7.4.4
RFC 3/8 drm/i2c: nxp-tda998x: ensure VIP output mux is properly set
In reply to Russell King - ARM LinuxWhen switching between various drivers for this device, it's possible that some critical registers are left containing values which affect the device operation. One such case encountered is the VIP output mux register. This defaults to 0x24 on powerup, but other drivers may set this to 0x12. This results in incorrect colours.
Fix this by ensuring that the register is always set to the power on default setting.
--- drivers/gpu/drm/i2c/tda998x_drv.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/gpu/drm/i2c/tda998x_drv.c +3 -0
@@ -110,6 +110,7 @@ struct tda998x_priv {#define REG_VIP_CNTRL_5 REG(0x00, 0x25)/* write */ # define VIP_CNTRL_5_CKCASE (1 << 0)# define VIP_CNTRL_5_SP_CNT (x) (((x) & 3) << 1) +#define REG_MUX_VP_VIP_OUT REG(0x00, 0x27)/* read/write */ #define REG_MAT_CONTRL REG(0x00, 0x80)/* write */ # define MAT_CONTRL_MAT_SC (x) (((x) & 3) << 0)# define MAT_CONTRL_MAT_BP (1 << 2)
@@ -438,6 +439,8 @@ tda998x_encoder_dpms(struct drm_encoder *encoder, int mode)switch (mode) {case DRM_MODE_DPMS_ON : +/* Write the default value MUX register */ +reg_write (encoder,REG_MUX_VP_VIP_OUT ,0x24 );/* enable audio and video ports */ reg_write (encoder,REG_ENA_AP ,0xff );reg_write (encoder,REG_ENA_VP_0 ,0xff );
Signature · 1 line
1.7.4.4
RFC 4/8 drm/i2c: nxp-tda998x: fix npix/nline programming
In reply to Russell King - ARM LinuxThe npix/nline registers are supposed to be programmed with the total number of pixels/lines, not the displayed pixels/lines, and not minus one either.
--- drivers/gpu/drm/i2c/tda998x_drv.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i2c/tda998x_drv.c +2 -2
@@ -586,8 +586,8 @@ tda998x_encoder_mode_set(struct drm_encoder *encoder,reg_set (encoder,REG_VIP_CNTRL_3 ,VIP_CNTRL_3_H_TGL );reg_write (encoder,REG_VIDFORMAT ,0x00 ); -reg_write16 (encoder,REG_NPIX_MSB , mode->hdisplay -1 ); -reg_write16 (encoder,REG_NLINE_MSB , mode->vdisplay -1 ); +reg_write16 (encoder,REG_NPIX_MSB , mode->htotal); +reg_write16 (encoder,REG_NLINE_MSB , mode->vtotal);reg_write16 (encoder,REG_VS_LINE_STRT_1_MSB , line_start);reg_write16 (encoder,REG_VS_LINE_END_1_MSB , line_end);reg_write16 (encoder,REG_VS_PIX_STRT_1_MSB , hs_start);
Signature · 1 line
1.7.4.4
RFC 5/8 drm/i2c: nxp-tda998x: prepare for video input configuration
In reply to Russell King - ARM Linux--- drivers/gpu/drm/i2c/tda998x_drv.c | 16 ++++++++++------ 1 files changed, 10 insertions(+), 6 deletions(-)
drivers/gpu/drm/i2c/tda998x_drv.c +10 -6
@@ -32,6 +32,9 @@ struct tda998x_priv {uint16_t rev;uint8_t current_page;int dpms; +u8 vip_cntrl_0; +u8 vip_cntrl_1; +u8 vip_cntrl_2; };#define to_tda998x_priv (x) ((struct tda998x_priv *)to_encoder_slave(x)->slave_priv)
@@ -447,12 +450,9 @@ tda998x_encoder_dpms(struct drm_encoder *encoder, int mode)reg_write (encoder,REG_ENA_VP_1 ,0xff );reg_write (encoder,REG_ENA_VP_2 ,0xff );/* set muxing after enabling ports: */ -reg_write (encoder,REG_VIP_CNTRL_0 , -VIP_CNTRL_0_SWAP_A (2 ) |VIP_CNTRL_0_SWAP_B (3 )); -reg_write (encoder,REG_VIP_CNTRL_1 , -VIP_CNTRL_1_SWAP_C (0 ) |VIP_CNTRL_1_SWAP_D (1 )); -reg_write (encoder,REG_VIP_CNTRL_2 , -VIP_CNTRL_2_SWAP_E (4 ) |VIP_CNTRL_2_SWAP_F (5 )); +reg_write (encoder,REG_VIP_CNTRL_0 , priv->vip_cntrl_0); +reg_write (encoder,REG_VIP_CNTRL_1 , priv->vip_cntrl_1); +reg_write (encoder,REG_VIP_CNTRL_2 , priv->vip_cntrl_2);break ;case DRM_MODE_DPMS_OFF :/* disable audio and video ports */
@@ -822,6 +822,10 @@ tda998x_encoder_init(struct i2c_client *client,if (!priv)return -ENOMEM ; + priv->vip_cntrl_0 =VIP_CNTRL_0_SWAP_A (2 ) |VIP_CNTRL_0_SWAP_B (3 ); + priv->vip_cntrl_1 =VIP_CNTRL_1_SWAP_C (0 ) |VIP_CNTRL_1_SWAP_D (1 ); + priv->vip_cntrl_2 =VIP_CNTRL_2_SWAP_E (4 ) |VIP_CNTRL_2_SWAP_F (5 ); + priv->current_page =0 ; priv->cec =i2c_new_dummy (client->adapter,0x34 ); priv->dpms =DRM_MODE_DPMS_OFF ;
Signature · 1 line
1.7.4.4
RFC 6/8 drm/i2c: nxp-tda998x: add video and audio input configuration
In reply to Russell King - ARM Linux--- drivers/gpu/drm/i2c/tda998x_drv.c | 308 ++++++++++++++++++++++++++++++++++++- 1 files changed, 301 insertions(+), 7 deletions(-)
drivers/gpu/drm/i2c/tda998x_drv.c +301 -7
@@ -23,7 +23,7 @@#include <drm/drm_crtc_helper.h> #include <drm/drm_encoder_slave.h> #include <drm/drm_edid.h> - +#include <drm/i2c/tda998x.h> #define DBG (fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)
@@ -32,9 +32,11 @@ struct tda998x_priv {uint16_t rev;uint8_t current_page;int dpms; +bool is_hdmi_sink;u8 vip_cntrl_0;u8 vip_cntrl_1;u8 vip_cntrl_2; +struct tda998x_encoder_params params; };#define to_tda998x_priv (x) ((struct tda998x_priv *)to_encoder_slave(x)->slave_priv)
@@ -71,10 +73,13 @@ struct tda998x_priv {# define I2C_MASTER_DIS_MM (1 << 0)# define I2C_MASTER_DIS_FILT (1 << 1)# define I2C_MASTER_APP_STRT_LAT (1 << 2) +#define REG_FEAT_POWERDOWN REG(0x00, 0x0e)/* read/write */ +# define FEAT_POWERDOWN_SPDIF (1 << 3)#define REG_INT_FLAGS_0 REG(0x00, 0x0f)/* read/write */ #define REG_INT_FLAGS_1 REG(0x00, 0x10)/* read/write */ #define REG_INT_FLAGS_2 REG(0x00, 0x11)/* read/write */ # define INT_FLAGS_2_EDID_BLK_RD (1 << 1) +#define REG_ENA_ACLK REG(0x00, 0x16)/* read/write */ #define REG_ENA_VP_0 REG(0x00, 0x18)/* read/write */ #define REG_ENA_VP_1 REG(0x00, 0x19)/* read/write */ #define REG_ENA_VP_2 REG(0x00, 0x1a)/* read/write */
@@ -113,6 +118,7 @@ struct tda998x_priv {#define REG_VIP_CNTRL_5 REG(0x00, 0x25)/* write */ # define VIP_CNTRL_5_CKCASE (1 << 0)# define VIP_CNTRL_5_SP_CNT (x) (((x) & 3) << 1) +#define REG_MUX_AP REG(0x00, 0x26)/* read/write */ #define REG_MUX_VP_VIP_OUT REG(0x00, 0x27)/* read/write */ #define REG_MAT_CONTRL REG(0x00, 0x80)/* write */ # define MAT_CONTRL_MAT_SC (x) (((x) & 3) << 0)
@@ -175,6 +181,12 @@ struct tda998x_priv {# define HVF_CNTRL_1_PAD (x) (((x) & 3) << 4)# define HVF_CNTRL_1_SEMI_PLANAR (1 << 6)#define REG_RPT_CNTRL REG(0x00, 0xf0)/* write */ +#define REG_I2S_FORMAT REG(0x00, 0xfc)/* read/write */ +# define I2S_FORMAT (x) (((x) & 3) << 0) +#define REG_AIP_CLKSEL REG(0x00, 0xfd)/* write */ +# define AIP_CLKSEL_FS (x) (((x) & 3) << 0) +# define AIP_CLKSEL_CLK_POL (x) (((x) & 1) << 2) +# define AIP_CLKSEL_AIP (x) (((x) & 7) << 3)/* Page 02h: PLL settings */
@@ -216,6 +228,11 @@ struct tda998x_priv {/* Page 10h: information frames and packets */ +#define REG_IF1_HB0 REG(0x10, 0x20)/* read/write */ +#define REG_IF2_HB0 REG(0x10, 0x40)/* read/write */ +#define REG_IF3_HB0 REG(0x10, 0x60)/* read/write */ +#define REG_IF4_HB0 REG(0x10, 0x80)/* read/write */ +#define REG_IF5_HB0 REG(0x10, 0xa0)/* read/write */ /* Page 11h: audio settings and content info packets */
@@ -225,10 +242,33 @@ struct tda998x_priv {# define AIP_CNTRL_0_LAYOUT (1 << 2)# define AIP_CNTRL_0_ACR_MAN (1 << 5)# define AIP_CNTRL_0_RST_CTS (1 << 6) +#define REG_CA_I2S REG(0x11, 0x01)/* read/write */ +# define CA_I2S_CA_I2S (x) (((x) & 31) << 0) +# define CA_I2S_HBR_CHSTAT (1 << 6) +#define REG_LATENCY_RD REG(0x11, 0x04)/* read/write */ +#define REG_ACR_CTS_0 REG(0x11, 0x05)/* read/write */ +#define REG_ACR_CTS_1 REG(0x11, 0x06)/* read/write */ +#define REG_ACR_CTS_2 REG(0x11, 0x07)/* read/write */ +#define REG_ACR_N_0 REG(0x11, 0x08)/* read/write */ +#define REG_ACR_N_1 REG(0x11, 0x09)/* read/write */ +#define REG_ACR_N_2 REG(0x11, 0x0a)/* read/write */ +#define REG_CTS_N REG(0x11, 0x0c)/* read/write */ +# define CTS_N_K (x) (((x) & 7) << 0) +# define CTS_N_M (x) (((x) & 3) << 4)#define REG_ENC_CNTRL REG(0x11, 0x0d)/* read/write */ # define ENC_CNTRL_RST_ENC (1 << 0)# define ENC_CNTRL_RST_SEL (1 << 1)# define ENC_CNTRL_CTL_CODE (x) (((x) & 3) << 2) +#define REG_DIP_FLAGS REG(0x11, 0x0e)/* read/write */ +# define DIP_FLAGS_ACR (1 << 0) +# define DIP_FLAGS_GC (1 << 1) +#define REG_DIP_IF_FLAGS REG(0x11, 0x0f)/* read/write */ +# define DIP_IF_FLAGS_IF1 (1 << 1) +# define DIP_IF_FLAGS_IF2 (1 << 2) +# define DIP_IF_FLAGS_IF3 (1 << 3) +# define DIP_IF_FLAGS_IF4 (1 << 4) +# define DIP_IF_FLAGS_IF5 (1 << 5) +#define REG_CH_STAT_B (x) REG(0x11, 0x14 + (x))/* read/write */ /* Page 12h: HDCP and OTP */
@@ -344,6 +384,23 @@ reg_read_range(struct drm_encoder *encoder, uint16_t reg, char *buf, int cnt)return ret; } +static void +reg_write_range (struct drm_encoder *encoder,uint16_t reg,uint8_t *p,int cnt) +{ +struct i2c_client *client =drm_i2c_encoder_get_client (encoder); +uint8_t buf[cnt+1 ]; +int ret; + + buf[0 ] =REG2ADDR (reg); +memcpy (&buf[1 ], p, cnt); + +set_page (encoder, reg); + + ret =i2c_master_send (client, buf, cnt +1 ); +if (ret <0 ) +dev_err (&client->dev,"Error %d writing to 0x%x\n" , ret, reg); +} +static uint8_t reg_read (struct drm_encoder *encoder,uint16_t reg) {
@@ -421,11 +478,192 @@ tda998x_reset(struct drm_encoder *encoder)reg_write (encoder,REG_PLL_SCG2 ,0x10 ); } +static uint8_t tda998x_cksum (uint8_t *buf,size_t bytes) +{ +uint8_t sum =0 ; + +while (bytes--) + sum += *buf++; +return (255 - sum) +1 ; +} + +#define HB (x) (x) +#define PB (x) (HB(2) + 1 + (x)) + +static void +tda998x_write_if (struct drm_encoder *encoder,uint8_t bit,uint16_t addr, +uint8_t *buf,size_t size) +{ + buf[PB (0 )] =tda998x_cksum (buf, size); + +reg_clear (encoder,REG_DIP_IF_FLAGS , bit); +reg_write_range (encoder, addr, buf, size); +reg_set (encoder,REG_DIP_IF_FLAGS , bit); +} + +static void +tda998x_write_aif (struct drm_encoder *encoder,struct tda998x_encoder_params *p) +{ +uint8_t buf[PB (5 ) +1 ]; + + buf[HB (0 )] =0x84 ; + buf[HB (1 )] =0x01 ; + buf[HB (2 )] =10 ; + buf[PB (0 )] =0 ; + buf[PB (1 )] = p->audio_frame[1 ] &0x07 ;/* CC */ + buf[PB (2 )] = p->audio_frame[2 ] &0x1c ;/* SF */ + buf[PB (4 )] = p->audio_frame[4 ]; + buf[PB (5 )] = p->audio_frame[5 ] &0xf8 ;/* DM_INH + LSV */ + +tda998x_write_if (encoder,DIP_IF_FLAGS_IF4 ,REG_IF4_HB0 , buf, +sizeof (buf)); +} + +static void +tda998x_write_avi (struct drm_encoder *encoder,struct drm_display_mode *mode) +{ +uint8_t buf[PB (13 ) +1 ]; + +memset (buf,0 ,sizeof (buf)); + buf[HB (0 )] =0x82 ; + buf[HB (1 )] =0x02 ; + buf[HB (2 )] =13 ; + buf[PB (4 )] =drm_match_cea_mode (mode); + +tda998x_write_if (encoder,DIP_IF_FLAGS_IF2 ,REG_IF2_HB0 , buf, +sizeof (buf)); +} + +static void tda998x_audio_mute (struct drm_encoder *encoder,bool on) +{ +if (on) { +reg_set (encoder,REG_SOFTRESET ,SOFTRESET_AUDIO ); +reg_clear (encoder,REG_SOFTRESET ,SOFTRESET_AUDIO ); +reg_set (encoder,REG_AIP_CNTRL_0 ,AIP_CNTRL_0_RST_FIFO ); + }else { +reg_clear (encoder,REG_AIP_CNTRL_0 ,AIP_CNTRL_0_RST_FIFO ); + } +} + +static void +tda998x_configure_audio (struct drm_encoder *encoder,struct tda998x_encoder_params *p) +{ +uint8_t buf[6 ], clksel_aip, clksel_fs, ca_i2s, cts_n; +uint32_t n; + +/* SetAudioPortConfig */ +reg_write (encoder,REG_ENA_AP , p->audio_cfg); +/* SetAudioClockPortConfig */ +reg_write (encoder,REG_ENA_ACLK , p->audio_clk_cfg); + +/* +* layout = channelAllocation ? 1 : 0; +* AudioInSetConfig(format, i2sFormat, channelAllocation, +* HDMITX_CHAN_NO_CHANGE, HDMITX_CLKPOLDSD_NO_CHANGE, +* HDMITX_SWAPDSD_NO_CHANGE, layout, HDMITX_LATENCY_CURRENT, +* dstRate) +*/ +switch (p->audio_format) { +case AFMT_SPDIF : +reg_write (encoder,REG_MUX_AP ,0x40 ); + clksel_aip =AIP_CLKSEL_AIP (0 ); +/* FS64SPDIF */ + clksel_fs =AIP_CLKSEL_FS (2 ); + cts_n =CTS_N_M (3 ) |CTS_N_K (3 ); + ca_i2s =0 ; +break ; + +case AFMT_I2S : +reg_write (encoder,REG_MUX_AP ,0x64 ); + clksel_aip =AIP_CLKSEL_AIP (1 ); +/* ACLK */ + clksel_fs =AIP_CLKSEL_FS (0 ); + cts_n =CTS_N_M (3 ) |CTS_N_K (3 ); + ca_i2s =CA_I2S_CA_I2S (0 /* channel allocation */ ); +break ; + } + +reg_write (encoder,REG_AIP_CLKSEL , clksel_aip); +// reg_write(encoder, REG_CA_I2S, ca_i2s); +// reg_write(encoder, REG_I2S_FORMAT, I2S_FORMAT(0 /* i2s format */)); +reg_clear (encoder,REG_AIP_CNTRL_0 ,AIP_CNTRL_0_LAYOUT ); +/* latency? */ + +/* get video format */ + +/* +* ctsRef = HDMITX_CTSREF_FS64SPDIF, uCtsX = HDMITX_CTSX_64 +* AudioInSetCts(ctsRef, rate, VidFmt, vOutFreq, +* HDMITX_CTS_AUTO, uCtsX, HDMITX_CTSK_USE_CTSX, +* HDMITX_CTSMTS_USE_CTSX, dstRate) +*/ +/* Auto CTS */ +reg_clear (encoder,REG_AIP_CNTRL_0 ,AIP_CNTRL_0_ACR_MAN ); +reg_write (encoder,REG_CTS_N , cts_n); +reg_write (encoder,REG_AUDIO_DIV ,3 ); + +/* +* This is the approximate value of N, which happens to be +* the recommended values for non-coherent clocks. +*/ + n =128 * p->audio_sample_rate /1000 ; + +/* Write the CTS and N values */ + buf[0 ] =0x44 ; + buf[1 ] =0x42 ; + buf[2 ] =0x01 ; + buf[3 ] = n; + buf[4 ] = n >>8 ; + buf[5 ] = n >>16 ; +reg_write_range (encoder,REG_ACR_CTS_0 , buf,6 ); + +/* Set CTS clock reference */ +reg_write (encoder,REG_AIP_CLKSEL , clksel_aip | clksel_fs); + +/* Reset CTS generator */ +reg_set (encoder,REG_AIP_CNTRL_0 ,AIP_CNTRL_0_RST_CTS ); +reg_clear (encoder,REG_AIP_CNTRL_0 ,AIP_CNTRL_0_RST_CTS ); + +/* Write the channel status */ + buf[0 ] =0x04 ; + buf[1 ] =0x00 ; + buf[2 ] =0x00 ; + buf[3 ] =0xf1 ; +reg_write_range (encoder,REG_CH_STAT_B (0 ), buf,4 ); + +tda998x_audio_mute (encoder, true); +mdelay (20 ); +tda998x_audio_mute (encoder, false); + +/* Write the audio information packet */ +tda998x_write_aif (encoder, p); +} +/* DRM encoder functions */ static void tda998x_encoder_set_config (struct drm_encoder *encoder,void *params) { +struct tda998x_priv *priv =to_tda998x_priv (encoder); +struct tda998x_encoder_params *p = params; + + priv->vip_cntrl_0 =VIP_CNTRL_0_SWAP_A (p->swap_a) | + (p->mirr_a ?VIP_CNTRL_0_MIRR_A :0 ) | +VIP_CNTRL_0_SWAP_B (p->swap_b) | + (p->mirr_b ?VIP_CNTRL_0_MIRR_B :0 ); + priv->vip_cntrl_1 =VIP_CNTRL_1_SWAP_C (p->swap_c) | + (p->mirr_c ?VIP_CNTRL_1_MIRR_C :0 ) | +VIP_CNTRL_1_SWAP_D (p->swap_d) | + (p->mirr_d ?VIP_CNTRL_1_MIRR_D :0 ); + priv->vip_cntrl_2 =VIP_CNTRL_2_SWAP_E (p->swap_e) | + (p->mirr_e ?VIP_CNTRL_2_MIRR_E :0 ) | +VIP_CNTRL_2_SWAP_F (p->swap_f) | + (p->mirr_f ?VIP_CNTRL_2_MIRR_F :0 ); + + priv->params = *p; + +if (p->audio_cfg) +tda998x_configure_audio (encoder, p); } static void
@@ -445,7 +683,8 @@ tda998x_encoder_dpms(struct drm_encoder *encoder, int mode)/* Write the default value MUX register */ reg_write (encoder,REG_MUX_VP_VIP_OUT ,0x24 );/* enable audio and video ports */ -reg_write (encoder,REG_ENA_AP ,0xff ); +// reg_write(encoder, REG_ENA_AP, priv->ena_ap); +// reg_write(encoder, REG_ENA_ACLK, priv->ena_aclk); reg_write (encoder,REG_ENA_VP_0 ,0xff );reg_write (encoder,REG_ENA_VP_1 ,0xff );reg_write (encoder,REG_ENA_VP_2 ,0xff );
@@ -456,7 +695,7 @@ tda998x_encoder_dpms(struct drm_encoder *encoder, int mode)break ;case DRM_MODE_DPMS_OFF :/* disable audio and video ports */ -reg_write (encoder,REG_ENA_AP ,0x00 ); +// reg_write(encoder, REG_ENA_AP, 0x00); reg_write (encoder,REG_ENA_VP_0 ,0x00 );reg_write (encoder,REG_ENA_VP_1 ,0x00 );reg_write (encoder,REG_ENA_VP_2 ,0x00 );
@@ -607,17 +846,31 @@ tda998x_encoder_mode_set(struct drm_encoder *encoder,reg_write16 (encoder,REG_REFPIX_MSB , ref_pix);reg_write16 (encoder,REG_REFLINE_MSB , ref_line); - reg =TBG_CNTRL_1_VHX_EXT_DE | -TBG_CNTRL_1_VHX_EXT_HS | -TBG_CNTRL_1_VHX_EXT_VS | -TBG_CNTRL_1_DWIN_DIS |/* HDCP off */ + reg =TBG_CNTRL_1_DWIN_DIS |/* HDCP off */ TBG_CNTRL_1_VH_TGL_2 ; +/* +* It is questionable whether this is correct - the nxp driver +* does not set VH_TGL_2 and the below for all display modes. +*/ if (mode->flags & (DRM_MODE_FLAG_NVSYNC |DRM_MODE_FLAG_NHSYNC )) reg |=TBG_CNTRL_1_VH_TGL_0 ;reg_set (encoder,REG_TBG_CNTRL_1 , reg);/* must be last register set: */ reg_clear (encoder,REG_TBG_CNTRL_0 ,TBG_CNTRL_0_SYNC_ONCE ); + +/* Only setup the info frames if the sink is HDMI */ +if (priv->is_hdmi_sink) { +/* We need to turn HDMI HDCP stuff on to get audio through */ +reg_clear (encoder,REG_TBG_CNTRL_1 ,TBG_CNTRL_1_DWIN_DIS ); +reg_write (encoder,REG_ENC_CNTRL ,ENC_CNTRL_CTL_CODE (1 )); +reg_set (encoder,REG_TX33 ,TX33_HDMI ); + +tda998x_write_avi (encoder, adjusted_mode); + +if (priv->params.audio_cfg) +tda998x_configure_audio (encoder, &priv->params); + } } static enum drm_connector_status
@@ -743,12 +996,14 @@ static int tda998x_encoder_get_modes(struct drm_encoder *encoder, struct drm_connector *connector) { + struct tda998x_priv *priv = to_tda998x_priv(encoder);struct edid *edid = (struct edid *)do_get_edid (encoder);int n =0 ;if (edid) {drm_mode_connector_update_edid_property (connector, edid); n =drm_add_edid_modes (connector, edid); + priv->is_hdmi_sink =drm_detect_hdmi_monitor (edid);kfree (edid); }
@@ -810,6 +1065,40 @@ tda998x_remove(struct i2c_client *client)return 0 ; } +static ssize_t i2c_read_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t size) +{ +struct drm_encoder *encoder =dev_get_drvdata (dev); +unsigned int page, addr; +unsigned char val; + +sscanf (buf,"%x %x" , &page, &addr); + + val =reg_read (encoder,REG (page, addr)); + +printk ("i2c read %02x @ page:%02x address:%02x\n" , val, page, addr); +return size; +} + +static ssize_t i2c_write_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t size) +{ +struct drm_encoder *encoder =dev_get_drvdata (dev); +unsigned int page, addr, mask, val; +unsigned char rval; + +sscanf (buf,"%x %x %x %x" , &page, &addr, &mask, &val); + + rval =reg_read (encoder,REG (page, addr)); + rval &= ~mask; + rval |= val & mask; +reg_write (encoder,REG (page, addr), rval); + +printk ("i2c write %02x @ page:%02x address:%02x\n" , rval, page, addr); +return size; +} + +static DEVICE_ATTR(i2c_read, S_IWUSR, NULL, i2c_read_store); +static DEVICE_ATTR(i2c_write, S_IWUSR, NULL, i2c_write_store); + static int tda998x_encoder_init(struct i2c_client *client, struct drm_device *dev,
@@ -817,6 +1106,11 @@ tda998x_encoder_init(struct i2c_client *client, {struct drm_encoder *encoder = &encoder_slave->base;struct tda998x_priv *priv; +/* debug */ +device_create_file (&client->dev, &dev_attr_i2c_read); +device_create_file (&client->dev, &dev_attr_i2c_write); +dev_set_drvdata (&client->dev, encoder); +/* debug end */ priv =kzalloc (sizeof (*priv),GFP_KERNEL );if (!priv)
Signature · 1 line
1.7.4.4
RFC 7/8 DRM: Dove: add support for drm tda19988 driver
In reply to Russell King - ARM Linux--- drivers/gpu/drm/dove/Kconfig | 9 ++ drivers/gpu/drm/dove/Makefile | 2 + drivers/gpu/drm/dove/dove_drm.h | 1 + drivers/gpu/drm/dove/dove_drv.c | 4 + drivers/gpu/drm/dove/dove_tda19988.c | 249 ++++++++++++++++++++++++++++++++++ 5 files changed, 265 insertions(+), 0 deletions(-) create mode 100644 drivers/gpu/drm/dove/dove_tda19988.c
drivers/gpu/drm/dove/Kconfig +9 -0
@@ -16,6 +16,15 @@ config DRM_DOVE if DRM_DOVE != n +config DRM_DOVE_TDA1998X + bool "Support TDA1998X HDMI output" + depends on I2C + depends on DRM_I2C_NXP_TDA998X = y + default y + help + Support the TDA1998x HDMI output device found on the Solid-Run + CuBox. + config DRM_DOVE_CURSOR bool "Enable Dove DRM hardware cursor support"
drivers/gpu/drm/dove/Makefile +2 -0
@@ -4,4 +4,6 @@ dove-y := dove_crtc.o dove_drv.o dove_fb.o dove_fbdev.o \ dove_gem.o dove_output.o dove_overlay.o dove-$(CONFIG_DEBUG_FS) += dove_debugfs.o +dove-$(CONFIG_DRM_DOVE_TDA1998X) += dove_tda19988.o + obj-$(CONFIG_DRM_DOVE) := dove.o
drivers/gpu/drm/dove/dove_drm.h +1 -0
@@ -57,6 +57,7 @@ void dove_overlay_destroy(struct drm_device *);void dove_drm_overlay_off (struct drm_device *,struct dove_overlay *);struct drm_connector *dove_drm_tda19988_create (struct drm_device *dev); +struct drm_connector *dove_drm_tda19988_nxp_create (struct drm_device *dev);int dove_drm_debugfs_init (struct drm_minor *);void dove_drm_debugfs_cleanup (struct drm_minor *);
drivers/gpu/drm/dove/dove_drv.c +4 -0
@@ -88,6 +88,10 @@ static int dove_drm_load(struct drm_device *dev, unsigned long flags) } } +#ifdef CONFIG_DRM_DOVE_TDA1998X +dove_drm_tda19988_create (dev); +#endif + ret =drm_vblank_init (dev, n);if (ret) goto err_kms;
drivers/gpu/drm/dove/dove_tda19988.c new file +249 -0
249 lines not on this page · raw message
Signature · 1 line
1.7.4.4
RFC 8/8 DRM: dove: provide a couple of generic slave encoder helpers
In reply to Russell King - ARM Linux--- drivers/gpu/drm/dove/dove_output.c | 20 ++++++++++++++++++++ drivers/gpu/drm/dove/dove_output.h | 6 ++++++ drivers/gpu/drm/dove/dove_tda19988.c | 23 ++--------------------- 3 files changed, 28 insertions(+), 21 deletions(-)
drivers/gpu/drm/dove/dove_output.c +20 -0
@@ -9,6 +9,7 @@#include "drm_crtc_helper.h" #include "drm_edid.h" #include "drm_helper.h" +#include "drm_encoder_slave.h" #include "dove_output.h" #include "dove_drm.h"
@@ -76,6 +77,25 @@ void dove_drm_encoder_commit(struct drm_encoder *encoder) funcs->dpms (encoder,DRM_MODE_DPMS_ON ); } +/* Shouldn't this be a generic helper function? */ +int dove_drm_slave_encoder_mode_valid (struct drm_connector *conn, +struct drm_display_mode *mode) +{ +struct drm_encoder *encoder = conn->encoder; +struct drm_encoder_slave *slave =to_encoder_slave (encoder); + +return slave->slave_funcs->mode_valid (encoder, mode); +} + +int dove_drm_slave_encoder_set_property (struct drm_connector *conn, +struct drm_property *property,uint64_t value) +{ +struct drm_encoder *encoder = conn->encoder; +struct drm_encoder_slave *slave =to_encoder_slave (encoder); + +return slave->slave_funcs->set_property (encoder, conn, property, value); +} +struct drm_connector *dove_output_create (struct drm_device *dev,const struct dove_output_type *type) {
drivers/gpu/drm/dove/dove_output.h +6 -0
@@ -20,6 +20,12 @@ struct drm_encoder *dove_drm_connector_best_encoder(struct drm_connector *conn);void dove_drm_encoder_prepare (struct drm_encoder *encoder);void dove_drm_encoder_commit (struct drm_encoder *encoder); +int dove_drm_slave_encoder_mode_valid (struct drm_connector *conn, +struct drm_display_mode *mode); + +int dove_drm_slave_encoder_set_property (struct drm_connector *conn, +struct drm_property *property,uint64_t value); +struct drm_connector *dove_output_create (struct drm_device *dev,const struct dove_output_type *);
drivers/gpu/drm/dove/dove_tda19988.c +2 -21
@@ -20,15 +20,6 @@ struct dove_drm_tda19988_encoder { };#define to_tda19988_encoder (enc) container_of(to_encoder_slave(enc), struct dove_drm_tda19988_encoder, slave) -static int dove_drm_connector_tda19988_mode_valid (struct drm_connector *conn, -struct drm_display_mode *mode) -{ -struct drm_encoder *enc = conn->encoder; -struct dove_drm_tda19988_encoder *tenc =to_tda19988_encoder (enc); - -return tenc->slave.slave_funcs->mode_valid (enc, mode); -} -static int dove_drm_connector_tda19988_get_modes (struct drm_connector *conn) {struct drm_display_mode *mode;
@@ -96,7 +87,7 @@ static const struct drm_encoder_funcs dove_drm_tda19988_enc_funcs = {static const struct drm_connector_helper_funcs dove_drm_conn_tda19988_helper_funcs = { .get_modes = dove_drm_connector_tda19988_get_modes, - .mode_valid = dove_drm_connector_tda19988_mode_valid, + .mode_valid = dove_drm_slave_encoder_mode_valid, .best_encoder = dove_drm_connector_best_encoder, };
@@ -225,22 +216,12 @@ static int dove_drm_conn_tda19988_create(struct drm_connector *conn,return ret; } -static int dove_drm_conn_tda19988_set_property (struct drm_connector *conn, -struct drm_property *property,uint64_t value) -{ -struct dove_drm_tda19988_encoder *tenc = -to_tda19988_encoder (conn->encoder); -struct drm_encoder_slave_funcs *sfuncs = tenc->slave.slave_funcs; - -return sfuncs->set_property (&tenc->slave.base, conn, property, value); -} -static const struct dove_output_type dove_drm_conn_tda19988 = { .connector_type =DRM_MODE_CONNECTOR_HDMIA , .polled =DRM_CONNECTOR_POLL_HPD , .detect = dove_drm_conn_tda19988_detect, .create = dove_drm_conn_tda19988_create, - .set_property = dove_drm_conn_tda19988_set_property, + .set_property = dove_drm_slave_encoder_set_property, };struct drm_connector *dove_drm_tda19988_create (struct drm_device *dev)
Signature · 1 line
1.7.4.4
Quoted 8 lines · On Thu, 16 May 2013 20:25:10 +0100 Russell King - ARM Linux…
What follows is my DRM driver for Dove, which I've been working on with the Solid-run Cubox, which only offers HDMI output via the TDA19988 chip.
Not everything is finished off perfectly in this driver; there's quite a number of ragged edges (particularly with page flipping, which is completely untested.)
Quoted 7 lines
I have most of the Xorg driver complete - none of the DRI interfaces checked yet (partly because that involves quite an amount of work with Mesa).
However, graphics, video overlay, interlacing, accelerated GPU via the original vivante support all works through this driver, with this driver providing the X pixmaps.
Hi Russell,
I quickly compared your dove drm driver and ours (Sebastian and me):
- CMA helper
You don't use DRM_KMS_CMA_HELPER and DRM_GEM_CMA_HELPER which would simplify some code.
- device tree
Our driver depends on the DT and, by this way, it may be used for various boards (Cubox, DB-MV88AP510 Development Board, CompuLab CM-A510 Board..). Especially, in the Cubox, only a HDMI screen may be connected, while the display controller permits connection of a smart panel (port A) and a VGA screen (port B).
Also, the driver could be used for different chips as the Armada 160 which has quite the same LCD controller (but one LCD only and no display controller - Sebastian's idea).
- module loading (si5351, tda998x)
As our driver is loaded by the Cubox DT, and as the auxilliary drivers (external clock, HDMI transmitter) may also be modules, a synchronization mechanism (inspired by the tegra drm driver) permits the driver to start when all the other drivers are also started.
- display controller
I implemented output port cloning (LCD 0 to port B) but it is not tested (I just have a Cubox and I think that Sebastian did not have time enough yet to do it).
- LCD handling
With our driver, the description of a smart panel (port A) may be done by the DT.
- hardware cursor
Our driver always proposes the HWC 32 (RGBA 64x64).
- LCD clocks
Each LCD may use one clock amongst 4 (AXI, LCD PLL and 2 external clocks). In our driver, the choice of the clock is done on each video mode change (Sebastian's idea).
- interlaced modes
While the code is there, I did not test the interlaced modes. Your code may be better.
- video overlay
Same as above: the code is in our driver (overlay plane), but it is not tested.
- private ioctls
It should be easy to add them in our driver and have an API compatible with your X server module.
- screen rotation (IRE)
This feature is needed when the Dove SoC is used in a tablet and does not exist in both drivers.
- VGA DAC
This feature is needed to get the VGA screen parameters (mode, dimensions) and does not exist in both drivers too.
Otherwise, there are some small differences in, for example, programming the LCD modes, or treating the vblank events.
What do you think about merging?
Signature · 7 lines
Ken ar c'hentañ | ** Breizh ha Linux atav! ** Jef | http://moinejf.free.fr/ _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 5 lines · Jean-Francois Moine
Quoted 3 lines · On Thu, 16 May 2013 20:25:10 +0100 Russell King - ARM Linux…
What follows is my DRM driver for Dove, which I've been working on with the Solid-run Cubox, which only offers HDMI output via the TDA19988 chip.
...
Quoted 10 lines
- device tree
Our driver depends on the DT and, by this way, it may be used for various boards (Cubox, DB-MV88AP510 Development Board, CompuLab CM-A510 Board..). Especially, in the Cubox, only a HDMI screen may be connected, while the display controller permits connection of a smart panel (port A) and a VGA screen (port B).
Also, the driver could be used for different chips as the Armada 160 which has quite the same LCD controller (but one LCD only and no display controller - Sebastian's idea).
Jean-Francois,
as Russell already mentioned, he is not on DT yet. It's not a big deal
to add the binding parsing to his driver though. Basically, there is only one thing that bothers me with Russell's driver: integrating TDA HDMI in the driver. But from what I have seen, it's almost equal to
our drm_slave_encoder stuff, so rebranding some functions should be
enough to allow any external encoder on lcdc.
Quoted 6 lines
- module loading (si5351, tda998x)
As our driver is loaded by the Cubox DT, and as the auxilliary drivers (external clock, HDMI transmitter) may also be modules, a synchronization mechanism (inspired by the tegra drm driver) permits the driver to start when all the other drivers are also started.
I agree on HDMI (when enabled through DT), but disagree on clock. There is some clocks internally that should be exploited even if there is no external clock available. This is actually something more general with common clock as it does not handle dynamic clocks yet.
Quoted 5 lines
- display controller
I implemented output port cloning (LCD 0 to port B) but it is not tested (I just have a Cubox and I think that Sebastian did not have time enough yet to do it).
Lack of time, sorry.
Would have to test on D2Plug which has both HDMI (also TDA) and VGA.
Quoted 4 lines
- LCD handling
With our driver, the description of a smart panel (port A) may be done by the DT.
In priciple, DT should support describing all possible panel modes. But of course, let's start with what we can test. SmartPanel and VGA in Jean-Francois and mine driver are just place holders. To mainline a common driver, I suggest to take Russell's driver as a start and add DT and stuff Russell agrees to.
Quoted 5 lines
- LCD clocks
Each LCD may use one clock amongst 4 (AXI, LCD PLL and 2 external clocks). In our driver, the choice of the clock is done on each video mode change (Sebastian's idea).
This is because of the dynamic clock restriction above. Reprobing clocks on each mode change will behave like dynamic clocks and should be removed if common clock framework supports it someday.
Then there is a heuristic, that tries to find the best matching clock starting with the current clock as lcdc itself can do integer division.
For Cubox with si5351 clock driver, it should be sufficient to rely on si5351 providing the clock. That will allow all HD modes, except 1600x1200@60 and above which exceed 160MHz max output frequency restriction of si5351.
Quoted 4 lines
- screen rotation (IRE)
This feature is needed when the Dove SoC is used in a tablet and does not exist in both drivers.
Again, let's implement what we can test - or is there anybody using secretary mode on his TV? BTW, IRE is only available on Dove, while lcdc controller can be reused on some PXAs.. try not to put too much Dove dependency into lcdc if possible.
Quoted 4 lines
- VGA DAC
This feature is needed to get the VGA screen parameters (mode, dimensions) and does not exist in both drivers too.
Do I still have a VGA monitor to test? ;)
Quoted 1 line
What do you think about merging?
As said above, I'd prefer to take Russell's driver as a start and merge ours (actually yours, as I just added stuff that slowed you down :P)
Sebastian
Quoted 3 lines · Jean-Francois Moine
Hi Russell,
I quickly compared your dove drm driver and ours (Sebastian and me):
I already said - I don't support DT. I don't run any DT based ARM devices, so I have no experience with DT. What I care more about is a working cubox platform, which afaik DT still can't offer yet.
Quoted 4 lines
- CMA helper
You don't use
DRM_KMS_CMA_HELPERandDRM_GEM_CMA_HELPERwhich would simplify some code.
Possibly, but the biggest win for me is having cacheable gem objects. CMA will be a retrograde step for those.
Quoted 7 lines
- device tree
Our driver depends on the DT and, by this way, it may be used for various boards (Cubox, DB-MV88AP510 Development Board, CompuLab CM-A510 Board..). Especially, in the Cubox, only a HDMI screen may be connected, while the display controller permits connection of a smart panel (port A) and a VGA screen (port B).
I only have a Cubox, so I can't test anything but HDMI.
Given that there's big questions about the polarity of signals coming out of the Armada 510 (with the invert bits 0, are the syncs positive or negative?) I wouldn't like to lead anyone up the path of thinking that this driver supports anything but the tested HDMI scenario yet.
As that information is not in any of the Armada 510 TRMs, and can only be discovered by physically probing the signals with a scope... that's on my todo list when I feel like dismantling the Cubox and getting the soldering iron out to separate the two boards so I can get access to the signals.
I've already tried to explain this to Sebastian on IRC, and kept getting nonsense back from him. "You need to program the whole chain". Yes, but that makes no sense to the question I was asking.
The reason is this:
+-----------------------------+ +------------------------+ | Armada510 | | TDA19988 | | LCD controller ---> switch ---------> switch --> processing | | VSYNC/HSYNC | | | +-----------------------------+ +------------------------+
The issue is that each 'switch' point is capable of inverting the sync signal. If you program both identically then you end up with inversion following another inversion. Which means no inversion. That's why I've found Sebastian's answers to be much less than helpful on this point.
What I have found with the NXP TDA19988 driver is that you need to get the input syncs to the TDA19988 set to the correct polarity for the TDA19988, which _isn't_ what is advertised in the EDID. The TDA19988 then has its own processing internally which places the appropriate sync codes onto the output data stream.
In some cases, getting this wrong shifts the displayed image by a few pixels/lines. In other cases you get no output or invalid output which isn't recognised by the connected device.
Quoted 3 lines
Also, the driver could be used for different chips as the Armada 160 which has quite the same LCD controller (but one LCD only and no display controller - Sebastian's idea).
That's no problem - you just provide my driver with only one IO space for the LCD controller, and it will only use one. If you have more than two, it will cope as well.
Quoted 6 lines
- module loading (si5351, tda998x)
As our driver is loaded by the Cubox DT, and as the auxilliary drivers (external clock, HDMI transmitter) may also be modules, a synchronization mechanism (inspired by the tegra drm driver) permits the driver to start when all the other drivers are also started.
The lack of Si5351 already gets tested on every cubox boot I do. That causes probe deferal, which allows the driver to properly start when it becomes ready.
Serial: 8250/16550 driver, 2 ports, IRQ sharing disabled serial8250.0: ttyS0 at MMIO 0xf1012000 (irq = 7) is a 16550A console [ttyS0] enabled
serial8250.1: ttyS1 at MMIO 0xf1012100 (irq = 8) is a 16550A [drm] Initialized drm 1.1.0 20060810 [drm:dove_drm_load] *ERROR* failed to get clock platform dove-drm: Driver dove-drm requests probe deferral
...
si5351 0-0060: registered si5351 i2c client
si5351 0-0060: external clock setup : clkdev = d827f820 cubox_extclk_setup : add alias 'extclk/dovefb.0' to clkout0 w 0 external clock setup done
...
dove-drm dove-drm: found TDA19988
[drm] Supports vblank timestamp caching Rev 1 (10.10.2010). [drm] No driver support for vblank timestamp query. dove-drm dove-drm: failed to read EDID
Console: switching to colour frame buffer device 160x45 dove-drm dove-drm: fb0: dove-drmfb frame buffer device dove-drm dove-drm: registered panic notifier
[drm] Initialized dove-drm 1.0.0 20120730 on minor 0
TDA998x is a different matter - I do need to propagate that error code, and then make a decision in the tda19988 connector whether to return -EPROBEDEFER.
(The failure to read EDID is caused by my HDMI switch, which at boot doesn't have the cubox selected, and so doesn't provide EDID until the cubox is selected.)
Quoted 5 lines
- display controller
I implemented output port cloning (LCD 0 to port B) but it is not tested (I just have a Cubox and I think that Sebastian did not have time enough yet to do it).
I didn't bother with this because - again - no access to port B on my hardware.
Quoted 4 lines
- LCD handling
With our driver, the description of a smart panel (port A) may be done by the DT.
That's simple enough to add - just another 'connector' even though it's the same physical connection out of the Armada 510.
Quoted 3 lines
- hardware cursor
Our driver always proposes the HWC 32 (RGBA 64x64).
Hardware cursor support is pretty useless.
In RGBA mode, it's not 64x64 but you get the choice of either 64x32 or 32x64. This is useless for Xorg's purposes, where it really wants a 64x64 cursor. And the XF86 Xorg backend really wants RGBA for hardware cursor, not 2bpp. So my conclusion is that hardware cursor is not worth any effort and I've a good mind to strip that out from my driver (which will simplify a few places.)
I've played with the idea of reducing a RGBA cursor down to 2bpp mode where we can fit the required size in, but that doesn't work very well.
Just because the hardware does something doesn't mean you should write code for it! :)
Quoted 5 lines
- LCD clocks
Each LCD may use one clock amongst 4 (AXI, LCD PLL and 2 external clocks). In our driver, the choice of the clock is done on each video mode change (Sebastian's idea).
Yes, this could be added to mine, probably fairly simply too, but for the purposes of the cubox...
Quoted 4 lines
- interlaced modes
While the code is there, I did not test the interlaced modes. Your code may be better.
I know mine works... I've run it at 1080i with the NXP TDA19988 driver.
Quoted 4 lines
- video overlay
Same as above: the code is in our driver (overlay plane), but it is not tested.
We as a family, have watched many hours of video on mine. :)
Quoted 12 lines
- private ioctls
It should be easy to add them in our driver and have an API compatible with your X server module.
- screen rotation (IRE)
This feature is needed when the Dove SoC is used in a tablet and does not exist in both drivers.
- VGA DAC
Quoted 7 lines
This feature is needed to get the VGA screen parameters (mode, dimensions) and does not exist in both drivers too.
Otherwise, there are some small differences in, for example, programming the LCD modes, or treating the vblank events.
What do you think about merging?
Yes, I think merging the two together would probably be sane. :)
Quoted 3 lines · On Fri, 17 May 2013 13:01:15 +0100 Russell King - ARM Linux…
I already said - I don't support DT. I don't run any DT based ARM devices, so I have no experience with DT. What I care more about is a working cubox platform, which afaik DT still can't offer yet.
I like the DT concept. All the job I did on the Cubox is based on DT, even when I was still using the aweful Marvell and NXP drivers. I have nothing which is Cubox specific in my kernel, but the driver modules.
Quoted 7 lines
Quoted 4 lines
- CMA helper
You don't use
DRM_KMS_CMA_HELPERandDRM_GEM_CMA_HELPERwhich would simplify some code.Possibly, but the biggest win for me is having cacheable gem objects. CMA will be a retrograde step for those.
I did not think yet about the possible problems which could be raised when the output of the video decoding engine, vMeta, will be the LCD overlay plane.
Quoted 9 lines
Quoted 7 lines
- device tree
Our driver depends on the DT and, by this way, it may be used for various boards (Cubox, DB-MV88AP510 Development Board, CompuLab CM-A510 Board..). Especially, in the Cubox, only a HDMI screen may be connected, while the display controller permits connection of a smart panel (port A) and a VGA screen (port B).
I only have a Cubox, so I can't test anything but HDMI.
Sebastian has other Dove based machine(s).
Quoted 10 lines
Given that there's big questions about the polarity of signals coming out of the Armada 510 (with the invert bits 0, are the syncs positive or negative?) I wouldn't like to lead anyone up the path of thinking that this driver supports anything but the tested HDMI scenario yet.
As that information is not in any of the Armada 510 TRMs, and can only be discovered by physically probing the signals with a scope... that's on my todo list when I feel like dismantling the Cubox and getting the soldering iron out to separate the two boards so I can get access to the signals.
Yes, from the beginning, Solidrun did not give us any information about their hardware..., nor about their software! It seems Rabeeh is only interested by a closed XBMC.
Quoted 23 lines
I've already tried to explain this to Sebastian on IRC, and kept getting nonsense back from him. "You need to program the whole chain". Yes, but that makes no sense to the question I was asking.
The reason is this:
+-----------------------------+ +------------------------+ | Armada510 | | TDA19988 | | LCD controller ---> switch ---------> switch --> processing | | VSYNC/HSYNC | | | +-----------------------------+ +------------------------+The issue is that each 'switch' point is capable of inverting the sync signal. If you program both identically then you end up with inversion following another inversion. Which means no inversion. That's why I've found Sebastian's answers to be much less than helpful on this point.
What I have found with the NXP TDA19988 driver is that you need to get the input syncs to the TDA19988 set to the correct polarity for the TDA19988, which _isn't_ what is advertised in the EDID. The TDA19988 then has its own processing internally which places the appropriate sync codes onto the output data stream.
Quoted 3 lines
In some cases, getting this wrong shifts the displayed image by a few pixels/lines. In other cases you get no output or invalid output which isn't recognised by the connected device.
Right. But I found that using Rob's tda988x driver gives me a full image on my TV set while with NXP's driver, I had more than 20 pixels lost on each side (left, right, top and bottom).
[snip]
Quoted 10 lines
Quoted 6 lines
- module loading (si5351, tda998x)
As our driver is loaded by the Cubox DT, and as the auxilliary drivers (external clock, HDMI transmitter) may also be modules, a synchronization mechanism (inspired by the tegra drm driver) permits the driver to start when all the other drivers are also started.
The lack of Si5351 already gets tested on every cubox boot I do. That causes probe deferal, which allows the driver to properly start when it becomes ready.
[snip]
That's what we have. I added an escape mechanism in case the si5351 is not present (I was waiting for the driver to be in the kernel). In this case, after a first -EPROBEDEFER, the LCD works with either AXI or the LCD PLL (both work fine with my TV set at 1920x1080p).
[snip]
Quoted 13 lines
Quoted 3 lines
- hardware cursor
Our driver always proposes the HWC 32 (RGBA 64x64).
Hardware cursor support is pretty useless.
In RGBA mode, it's not 64x64 but you get the choice of either 64x32 or 32x64. This is useless for Xorg's purposes, where it really wants a 64x64 cursor. And the XF86 Xorg backend really wants RGBA for hardware cursor, not 2bpp. So my conclusion is that hardware cursor is not worth any effort and I've a good mind to strip that out from my driver (which will simplify a few places.)
Quoted 5 lines
I've played with the idea of reducing a RGBA cursor down to 2bpp mode where we can fit the required size in, but that doesn't work very well.
Just because the hardware does something doesn't mean you should write code for it! :)
Maybe I did not explain correctly: the colored cursor maybe RGB888 + transparency (64x64) or full ARGB (64x32 or 32x64). I coded the first case. And, yes, I better like a hardware cursor: it asks for less computation, and I get it immediately at graphic starting time!
[snip]
Quoted 6 lines
Quoted 4 lines
- video overlay
Same as above: the code is in our driver (overlay plane), but it is not tested.
We as a family, have watched many hours of video on mine. :)
I wrote the drm driver because there was no easy way to use the video decoding engine with vlc and the Marvell's drivers. Now that the driver runs, the next step was to extend the 'modesetting' X server module to handle the overlay planes (I wonder why nobody did it yet). But, if you already have something running, I'd be glad to get it...
[snip]
Quoted 3 lines
Quoted 1 line
What do you think about merging?
Yes, I think merging the two together would probably be sane. :)
OK.
The first step is "DT or not DT"? For me, the DT is more flexible (one or two LCDs, smart panel definition, display controller or not..) and permits easy inclusion of out of tree drivers as the private VPU and GPU ones.
Signature · 7 lines
Ken ar c'hentañ | ** Breizh ha Linux atav! ** Jef | http://moinejf.free.fr/ _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 7 lines · Jean-Francois Moine
Quoted 5 lines · On Fri, 17 May 2013 13:01:15 +0100 Russell King - ARM Linux…
Quoted 4 lines
- CMA helper
You don't use
DRM_KMS_CMA_HELPERandDRM_GEM_CMA_HELPERwhich would simplify some code.
Quoted 6 lines
Quoted 2 lines
Possibly, but the biggest win for me is having cacheable gem objects. CMA will be a retrograde step for those.
I did not think yet about the possible problems which could be raised when the output of the video decoding engine, vMeta, will be the LCD overlay plane.
Not talking about vMeta here, but the vivante GPU. vMeta has entirely different requirements because vMeta does not have any IOMMU, whereas the GPU has a built-in MMU. That alone allows us to deal with SHM-backed buffer objects in a sensible way.
Quoted 23 lines
Quoted 23 lines
I've already tried to explain this to Sebastian on IRC, and kept getting nonsense back from him. "You need to program the whole chain". Yes, but that makes no sense to the question I was asking.
The reason is this:
+-----------------------------+ +------------------------+ | Armada510 | | TDA19988 | | LCD controller ---> switch ---------> switch --> processing | | VSYNC/HSYNC | | | +-----------------------------+ +------------------------+The issue is that each 'switch' point is capable of inverting the sync signal. If you program both identically then you end up with inversion following another inversion. Which means no inversion. That's why I've found Sebastian's answers to be much less than helpful on this point.
What I have found with the NXP TDA19988 driver is that you need to get the input syncs to the TDA19988 set to the correct polarity for the TDA19988, which _isn't_ what is advertised in the EDID. The TDA19988 then has its own processing internally which places the appropriate sync codes onto the output data stream.
Quoted 7 lines
Quoted 3 lines
In some cases, getting this wrong shifts the displayed image by a few pixels/lines. In other cases you get no output or invalid output which isn't recognised by the connected device.
Right. But I found that using Rob's tda988x driver gives me a full image on my TV set while with NXP's driver, I had more than 20 pixels lost on each side (left, right, top and bottom).
At the moment, Rob's driver has many problems, one of them is that it mis-programs the NPIX and NLINE registers in such a way that it causes my TV to complain about the input. Basically, the driver as it stands in mainline is totally unusable for me. The TV doesn't recognise any output.
Yet, program the device with the CEA mode (where it uses its own internal settings) and lo and behold, picture. I tracked that down to NPIX and NLINE being completely wrong.
What you're actually seeing is what's called "overscan" which is something that TVs do with broadcast images. The left and right pixels, top and bottom lines are always "off screen". However, our computer displays, we expect the display to be "underscanned" where the top left and bottom right most pixels correspond with the corners of the display.
There are bits in the HDMI data stream which tell the TV whether the display should be overscanned or underscanned. Unfortunately, many TVs choose to ignore this data (they're permitted to do this by the standards), and instead decide that if it's a computer resolution, they will underscan, otherwise if it's a broadcast resolution, they will overscan.
That's not a bug in the transmission. That's a bug in the display device.
Quoted 16 lines
Quoted 16 lines
Quoted 3 lines
- hardware cursor
Our driver always proposes the HWC 32 (RGBA 64x64).
Hardware cursor support is pretty useless.
In RGBA mode, it's not 64x64 but you get the choice of either 64x32 or 32x64. This is useless for Xorg's purposes, where it really wants a 64x64 cursor. And the XF86 Xorg backend really wants RGBA for hardware cursor, not 2bpp. So my conclusion is that hardware cursor is not worth any effort and I've a good mind to strip that out from my driver (which will simplify a few places.)
I've played with the idea of reducing a RGBA cursor down to 2bpp mode where we can fit the required size in, but that doesn't work very well.
Quoted 7 lines
Quoted 2 lines
Just because the hardware does something doesn't mean you should write code for it! :)
Maybe I did not explain correctly: the colored cursor maybe RGB888 + transparency (64x64) or full ARGB (64x32 or 32x64). I coded the first case. And, yes, I better like a hardware cursor: it asks for less computation, and I get it immediately at graphic starting time!
Interesting. Where did you find the documentation for the transparency? The FS lists HWC32_TRANS_CNTL but omits to specify where that gets used.
Quoted 6 lines
[snip]Quoted 5 lines
Quoted 4 lines
- video overlay
Same as above: the code is in our driver (overlay plane), but it is not tested.
Quoted 7 lines
Quoted 1 line
We as a family, have watched many hours of video on mine. :)
I wrote the drm driver because there was no easy way to use the video decoding engine with vlc and the Marvell's drivers. Now that the driver runs, the next step was to extend the 'modesetting' X server module to handle the overlay planes (I wonder why nobody did it yet). But, if you already have something running, I'd be glad to get it...
Ahem. You're duplicating all my work. I've had working vlc for mpeg2 and mpeg4 (not h264) since August/September last year!
Quoted 11 lines
[snip]Quoted 3 lines
Quoted 1 line
What do you think about merging?
Yes, I think merging the two together would probably be sane. :)
OK.
The first step is "DT or not DT"? For me, the DT is more flexible (one or two LCDs, smart panel definition, display controller or not..) and permits easy inclusion of out of tree drivers as the private VPU and GPU ones.
I'd argue supporting both. :)
Quoted 8 lines · Russell King - ARM Linux
Quoted 4 lines · Jean-Francois Moine
Maybe I did not explain correctly: the colored cursor maybe RGB888 + transparency (64x64) or full ARGB (64x32 or 32x64). I coded the first case. And, yes, I better like a hardware cursor: it asks for less computation, and I get it immediately at graphic starting time!
Interesting. Where did you find the documentation for the transparency? The FS lists
HWC32_TRANS_CNTLbut omits to specify where that gets used.
Ignore that, I just found the reference (unfortunately wrapped so evince couldn't find it with a search.)
Quoted 7 lines · On Fri, 17 May 2013 19:00:29 +0100 Russell King - ARM Linux…
Quoted 4 lines
Maybe I did not explain correctly: the colored cursor maybe RGB888 + transparency (64x64) or full ARGB (64x32 or 32x64). I coded the first case. And, yes, I better like a hardware cursor: it asks for less computation, and I get it immediately at graphic starting time!
Interesting. Where did you find the documentation for the transparency? The FS lists
HWC32_TRANS_CNTLbut omits to specify where that gets used.
Simply in the ¶ 11.3.2.1. The HWC32_TRANS_CNTL SRAM is loaded like the HWC 2bpp, but with 00 transparent / 01 RGB.
Quoted 6 lines
Quoted 4 lines
The first step is "DT or not DT"? For me, the DT is more flexible (one or two LCDs, smart panel definition, display controller or not..) and permits easy inclusion of out of tree drivers as the private VPU and GPU ones.
I'd argue supporting both. :)
Not easy!
If you have not yet looked at our driver, here is how it starts:
- in '/', the DT contains
video {
compatible = "marvell,dove-video";
};which loads the dove-drm module.
- its module init function registers the lcd driver, the dcon driver and the drm driver.
- the lcd probe function tries to get all the resources for the specific LCD from the DT, including the clocks and the HDMI transmitter.
If some resource is lacking, it deferes.
When all resources are there, it says "present" to the drm driver (see below).
The resources of a LCD are declared in the DT by something like:
&lcd0 { /* the iomem and irq are declared
* in the Dove global DT */ status = "okay"; /* this LCD is present and usable */ clocks = <&core_clk 3>, <0>, <&lcdclk>, <&si5351 0>; /* 3 usable clocks */ marvell,port-type = <11>; /* HDMIA */ marvell,external-encoder = <&tda998x>; /* HDMI slave encoder */
};
- the dcon probe function gets its resources and says "present" to the drm driver.
Its DT declaration is just:
&dcon { status = "okay"; }; /* iomem and irq in the Dove DT */
- the drm probe function scans all the DT, counting its usuable devices, (i.e. the LCDs and the dcon), and decrement the "present" variable accordingly.
- when the "present" variable is null, the active devices have all their resources, and, then, the drm driver is activated by a call to drm_platform_init().
I don't see clearly how to do that with a static initialization, and I don't want to write a "cubox-setup.c". A kernel CONFIG_CUBOX ?
Signature · 7 lines
Ken ar c'hentañ | ** Breizh ha Linux atav! ** Jef | http://moinejf.free.fr/ _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [RFC 3/8] drm/i2c: nxp-tda998x: ensure VIP output mux is properly set
In reply to Russell KingQuoted 27 lines · On Thu, 16 May 2013 20:26:18 +0100 Russell King <[email protected]>…
When switching between various drivers for this device, it's possible that some critical registers are left containing values which affect the device operation. One such case encountered is the VIP output mux register. This defaults to
0x24on powerup, but other drivers may set this to0x12. This results in incorrect colours.Fix this by ensuring that the register is always set to the power on default setting.
Signed-off-by Russell King <[email protected]>--- drivers/gpu/drm/i2c/tda998x_drv.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)drivers/gpu/drm/i2c/tda998x_drv.c +1
-0@@ -110,6 +110,7 @@ struct tda998x_priv {#define REG_VIP_CNTRL_5 REG(0x00, 0x25)/* write */ # define VIP_CNTRL_5_CKCASE (1 << 0)# define VIP_CNTRL_5_SP_CNT (x) (((x) & 3) << 1) +#define REG_MUX_VP_VIP_OUT REG(0x00, 0x27)/* read/write */ #define REG_MAT_CONTRL REG(0x00, 0x80)/* write */ # define MAT_CONTRL_MAT_SC (x) (((x) & 3) << 0)# define MAT_CONTRL_MAT_BP (1 << 2)
drivers/gpu/drm/i2c/tda998x_drv.c tda998x_encoder_dpms(struct drm_encoder *encoder, int mode) · line 446
Quoted 8 lines
drivers/gpu/drm/i2c/tda998x_drv.c +2
-0@@ -438,6 +439,8 @@ tda998x_encoder_dpms(struct drm_encoder *encoder, int mode)switch (mode) {case DRM_MODE_DPMS_ON : +/* Write the default value MUX register */ +reg_write (encoder,REG_MUX_VP_VIP_OUT ,0x24 );/* enable audio and video ports */ reg_write (encoder,REG_ENA_AP ,0xff );reg_write (encoder,REG_ENA_VP_0 ,0xff );
This register is never touched. Should not this setting better go at reset time (in tda998x_reset)?
Signature · 7 lines
Ken ar c'hentañ | ** Breizh ha Linux atav! ** Jef | http://moinejf.free.fr/ _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
cover Add DT support to rmk's Dove DRM driver
In reply to Russell King - ARM LinuxThis RFC adds DT support to the DRM driver for Marvell Dove SoCs posted by Russell King recently. For those booting DT with appended ATAGs, remember to reduce probed memory by passing mem=1008M as kernel parameter.
There was an include missing in Russell's RFC that is also added.
Sebastian Hesselbarth (4):
ARM: dove: add lcd controller DT nodes
ARM: dove: add video card node for SolidRun CuBox
DRM: add OF support for Dove DRM driver
DRM: tda998x: add missing include
arch/arm/boot/dts/dove-cubox.dts | 16 +++++- arch/arm/boot/dts/dove.dtsi | 16 ++++++ drivers/gpu/drm/dove/Kconfig | 4 ++ drivers/gpu/drm/dove/Makefile | 1 + drivers/gpu/drm/dove/dove_card.c | 110 ++++++++++++++++++++++++++++++++++++++ include/drm/i2c/tda998x.h | 23 ++++++++ 6 files changed, 169 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/dove/dove_card.c create mode 100644 include/drm/i2c/tda998x.h
---
Cc: Russell King <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: Jason Cooper <[email protected]>
Cc: Jean-Francois Moine <[email protected]>
Signature · 1 line
1.7.10.4
RFC 1/4 ARM: dove: add lcd controller DT nodes
This adds device tree nodes for the lcd controllers found on Marvell Dove SoCs. For now, there is no DT documentation and clocks property should refer to clock connected to extclk0 pin.
---
Cc: Russell King <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: Jason Cooper <[email protected]>
Cc: Jean-Francois Moine <[email protected]>
--- arch/arm/boot/dts/dove.dtsi | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
arch/arm/boot/dts/dove.dtsi +16 -0
@@ -258,5 +258,21 @@ dmacap,xor; }; }; + + lcd0: lcd-controller@820000 { + compatible = "marvell,dove-lcd"; + reg = <0x820000 0x200>; + interrupts = <47>; + clocks = <0>; + status = "disabled"; + }; + + lcd1: lcd-controller@810000 { + compatible = "marvell,dove-lcd"; + reg = <0x810000 0x200>; + interrupts = <46>; + clocks = <0>; + status = "disabled"; + }; }; };
Signature · 1 line
1.7.10.4
RFC 2/4 ARM: dove: add video card node for SolidRun CuBox
In reply to Sebastian HesselbarthThis adds a video card node required for rmk's dove_drm driver. Reg property matches reserved memory region (currently 16M at top of memory), clocks property should carry extclk0 for now.
---
Cc: Russell King <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: Jason Cooper <[email protected]>
Cc: Jean-Francois Moine <[email protected]>
--- arch/arm/boot/dts/dove-cubox.dts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
arch/arm/boot/dts/dove-cubox.dts +15 -1
@@ -8,7 +8,7 @@ memory { device_type = "memory"; - reg = <0x00000000 0x40000000>; + reg = <0x00000000 0x3f000000>; }; chosen {
@@ -52,10 +52,24 @@ #clock-cells = <0>; }; }; + + video { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + ranges; + + vcard: video-card { + compatible = "marvell,dove-video-card"; + reg = <0x3f000000 0x1000000>; + clocks = <&si5351 0>, <&si5351 0>; + }; + }; }; &uart0 { status = "okay"; }; &sata0 { status = "okay"; }; +&lcd0 { status = "okay"; }; &i2c0 { status = "okay";
Signature · 1 line
1.7.10.4
RFC 3/4 DRM: add OF support for Dove DRM driver
In reply to Sebastian HesselbarthThis adds OF support for the Dove DRM driver recently posted as RFC by Russell King.
---
Cc: Russell King <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: Jason Cooper <[email protected]>
Cc: Jean-Francois Moine <[email protected]>
--- drivers/gpu/drm/dove/Kconfig | 4 ++ drivers/gpu/drm/dove/Makefile | 1 + drivers/gpu/drm/dove/dove_card.c | 110 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 115 insertions(+) create mode 100644 drivers/gpu/drm/dove/dove_card.c
drivers/gpu/drm/dove/Kconfig +4 -0
@@ -28,4 +28,8 @@ config DRM_DOVE_TDA1998X config DRM_DOVE_CURSOR bool "Enable Dove DRM hardware cursor support" +config DRM_DOVE_OF + bool "Enable Dove DRM OF video card" + depends on OF + endif
drivers/gpu/drm/dove/Makefile +1 -0
@@ -5,5 +5,6 @@ dove-y := dove_crtc.o dove_drv.o dove_fb.o dove_fbdev.o \ dove-$(CONFIG_DEBUG_FS) += dove_debugfs.o dove-$(CONFIG_DRM_DOVE_TDA1998X) += dove_tda19988.o +dove-$(CONFIG_DRM_DOVE_OF) += dove_card.o obj-$(CONFIG_DRM_DOVE) := dove.o
drivers/gpu/drm/dove/dove_card.c new file +110 -0
110 lines not on this page · raw message
Signature · 1 line
1.7.10.4
RFC 4/4 DRM: tda998x: add missing include
In reply to Sebastian HesselbarthThe RFC sent by Russell King was missing an include for tda998x. This is just a compatible clone to remember Russell to add that later.
---
Cc: Russell King <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: Jason Cooper <[email protected]>
Cc: Jean-Francois Moine <[email protected]>
--- include/drm/i2c/tda998x.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 include/drm/i2c/tda998x.h
include/drm/i2c/tda998x.h new file +23 -0
@@ -0,0 +1,23 @@ +#ifndef __TDA998X_H__ +#define __TDA998X_H__ + +enum tda998x_audio_format { +AFMT_I2S , +AFMT_SPDIF , +}; + +struct tda998x_encoder_params { +int audio_cfg; +int audio_clk_cfg; +enum tda998x_audio_format audio_format; +int audio_sample_rate; +char audio_frame[6 ]; +int swap_a, mirr_a; +int swap_b, mirr_b; +int swap_c, mirr_c; +int swap_d, mirr_d; +int swap_e, mirr_e; +int swap_f, mirr_f; +}; + +#endif
Signature · 1 line
1.7.10.4
Re: [RFC 2/4] ARM: dove: add video card node for SolidRun CuBox
In reply to Sebastian HesselbarthQuoted 43 lines · On Sat, 18 May 2013 19:12:17 +0200 Sebastian Hesselbarth…
This adds a video card node required for rmk's
dove_drmdriver. Reg property matches reserved memory region (currently 16M at top of memory), clocks property should carry extclk0 for now.Signed-off-by Sebastian Hesselbarth <[email protected]>---
Cc: Russell King <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: Jason Cooper <[email protected]>
Cc: Jean-Francois Moine <[email protected]>--- arch/arm/boot/dts/dove-cubox.dts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)arch/arm/boot/dts/dove-cubox.dts +12
-1@@ -8,7 +8,7 @@ memory { device_type = "memory"; - reg = <0x00000000 0x40000000>; + reg = <0x00000000 0x3f000000>; }; chosen {@@ -52,10 +52,24 @@ #clock-cells = <0>; }; }; + + video { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + ranges; + + vcard: video-card { + compatible = "marvell,dove-video-card"; + reg = <0x3f000000 0x1000000>; + clocks = <&si5351 0>, <&si5351 0>;
arch/arm/boot/dts/dove-cubox.dts line 75
Quoted 10 lines
arch/arm/boot/dts/dove-cubox.dts +3
-0+ }; + }; }; &uart0 { status = "okay"; }; &sata0 { status = "okay"; }; +&lcd0 { status = "okay"; }; &i2c0 { status = "okay";
May you explain a bit more this strange hack?
Signature · 7 lines
Ken ar c'hentañ | ** Breizh ha Linux atav! ** Jef | http://moinejf.free.fr/ _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [RFC 3/4] DRM: add OF support for Dove DRM driver
In reply to Sebastian HesselbarthQuoted 147 lines · On Sat, 18 May 2013 19:12:18 +0200 Sebastian Hesselbarth…
This adds OF support for the Dove DRM driver recently posted as RFC by Russell King.
Signed-off-by Sebastian Hesselbarth <[email protected]>---
Cc: Russell King <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: Jason Cooper <[email protected]>
Cc: Jean-Francois Moine <[email protected]>--- drivers/gpu/drm/dove/Kconfig | 4 ++ drivers/gpu/drm/dove/Makefile | 1 + drivers/gpu/drm/dove/dove_card.c | 110 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 115 insertions(+) create mode 100644 drivers/gpu/drm/dove/dove_card.cdrivers/gpu/drm/dove/Kconfig +4
-0@@ -28,4 +28,8 @@ config DRM_DOVE_TDA1998X config DRM_DOVE_CURSOR bool "Enable Dove DRM hardware cursor support" +config DRM_DOVE_OF + bool "Enable Dove DRM OF video card" + depends on OF + endifdrivers/gpu/drm/dove/Makefile +1
-0@@ -5,5 +5,6 @@ dove-y := dove_crtc.o dove_drv.o dove_fb.o dove_fbdev.o \ dove-$(CONFIG_DEBUG_FS) += dove_debugfs.o dove-$(CONFIG_DRM_DOVE_TDA1998X) += dove_tda19988.o +dove-$(CONFIG_DRM_DOVE_OF) += dove_card.o obj-$(CONFIG_DRM_DOVE) := dove.odrivers/gpu/drm/dove/dove_card.c new file +100
-0@@ -0,0 +1,110 @@ +/* +* Copyright (C) 2013 +* Sebastian Hesselbarth <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ +#include <linux/clk.h> +#include <linux/clkdev.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/of_address.h> +#include <linux/of_irq.h> +#include <linux/of_platform.h> +#include <linux/platform_device.h> + +#define DOVE_LCD0_BASE 0x20000 +#define DOVE_LCD1_BASE 0x10000 + +static struct resource dove_drm_resources[5 ]; +static struct platform_device dove_drm_platform_device = { + .name ="dove-drm" , + .id =0 , + .dev = { .coherent_dma_mask = ~0 , }, + .resource = dove_drm_resources, +}; + +static int dove_card_probe (struct platform_device *pdev) +{ +struct device_node *np = pdev->dev.of_node; +struct device_node *lcdnp; +struct resource *res = dove_drm_resources; +int ret, n =0 , crtcs =0 ; + +/* get video memory resource */ +if (of_address_to_resource (np,0 , &res[n++])) { +dev_err (&pdev->dev,"invalid or missing video memory\n" ); +return -EINVAL ; + } + +/* get reg and irq resource from each enabled lcdc */ +for_each_compatible_node (lcdnp,NULL ,"marvell,dove-lcd" ) { +struct clk_lookup *cl; +struct clk *clk; +int lcd; + +if (!of_device_is_available (lcdnp)) +continue ; + + ret =of_address_to_resource (lcdnp,0 , &res[n]); +if (ret) +return ret; + lcd = ((res[n].start &0xfffff ) ==DOVE_LCD1_BASE ); + n++; + + ret =of_irq_to_resource (lcdnp,0 , &res[n]); +if (ret <0 ) +return ret; + n++; + + crtcs++; + + clk =clk_get (&pdev->dev,NULL ); +if (IS_ERR (clk)) { + ret =PTR_ERR (clk); +if (ret == -ENOENT ) +return -EPROBE_DEFER ; +return ret; + } + +/* add clock alias for dovefb.0 */ + cl =clkdev_alloc (clk,"extclk" ,"dovefb.0" ); +if (cl) +clkdev_add (cl); +clk_put (clk); + } + +if (!crtcs) +return -ENODEV ; + + dove_drm_platform_device.num_resources = n; + ret =platform_device_register (&dove_drm_platform_device); +if (ret) { +dev_err (&pdev->dev,"unable to register drm device\n" ); +return ret; + } + +return 0 ; +} + +static const struct of_device_id dove_card_of_ids[] = { + { .compatible ="marvell,dove-video-card" , }, + { } +}; +MODULE_DEVICE_TABLE (of, dove_card_of_ids); + +static struct platform_driver dove_card_driver = { + .probe = dove_card_probe, + .driver = {
drivers/gpu/drm/dove/dove_card.c line 110
Quoted 10 lines
drivers/gpu/drm/dove/dove_card.c new file +10
-0+ .owner = THIS_MODULE, + .name = "dove-drm-card", + .of_match_table = of_match_ptr(dove_card_of_ids), + }, +}; +module_platform_driver (dove_card_driver); + +MODULE_AUTHOR ("Sebastian Hesselbarth <[email protected]>" ); +MODULE_DESCRIPTION ("Dove DRM Graphics Card" ); +MODULE_LICENSE ("GPL" );
It seems we are moving backwards:
- what about the display controller?
- how do you clone the lcd 0 output to the port B?
- what occurs when the si5351 and the tda998x are modules?
My driver had the same layout as Russell's when I proposed it to you and when you insisted to handle the 2 LCDs and the 2 ports as one card. I spent 2 months to have a nice design and you put it to garbage! I am not happy...
Signature · 7 lines
Ken ar c'hentañ | ** Breizh ha Linux atav! ** Jef | http://moinejf.free.fr/ _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [RFC 4/4] DRM: tda998x: add missing include
In reply to Sebastian HesselbarthQuoted 34 lines · On Sat, 18 May 2013 19:12:19 +0200 Sebastian Hesselbarth…
The RFC sent by Russell King was missing an include for tda998x. This is just a compatible clone to remember Russell to add that later.
Signed-off-by Sebastian Hesselbarth <[email protected]>---
Cc: Russell King <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: Jason Cooper <[email protected]>
Cc: Jean-Francois Moine <[email protected]>--- include/drm/i2c/tda998x.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 include/drm/i2c/tda998x.hinclude/drm/i2c/tda998x.h new file +13
-0@@ -0,0 +1,23 @@ +#ifndef __TDA998X_H__ +#define __TDA998X_H__ + +enum tda998x_audio_format { + AFMT_I2S, + AFMT_SPDIF, +}; + +struct tda998x_encoder_params { + int audio_cfg; + int audio_clk_cfg; + enum tda998x_audio_format audio_format; + int audio_sample_rate;
include/drm/i2c/tda998x.h line 23
Quoted 10 lines
include/drm/i2c/tda998x.h new file +10
-0+char audio_frame[6 ]; +int swap_a, mirr_a; +int swap_b, mirr_b; +int swap_c, mirr_c; +int swap_d, mirr_d; +int swap_e, mirr_e; + int swap_f, mirr_f; +}; + +#endif
These parameters should not be there. It seems to me that the DT is the right place.
Signature · 7 lines
Ken ar c'hentañ | ** Breizh ha Linux atav! ** Jef | http://moinejf.free.fr/ _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [RFC 3/4] DRM: add OF support for Dove DRM driver
In reply to Jean-Francois MoineQuoted 5 lines · Jean-Francois Moine
Quoted 3 lines · On Sat, 18 May 2013 19:12:18 +0200 Sebastian…
This adds OF support for the Dove DRM driver recently posted as RFC by Russell King.
...
Jean-Francois,
one thing first: It is an RFC! It is to allow you to _test_ rmk's driver on DT. Nothing more, nothing less.
I will comment on your questions but that all can change for a full patch set of rmk, you, or me.
The "video-card" node combines all devices that will be available and active on a specific Dove board. As you may have noticed about rmk's driver, it is registering crtcs from IORESOURCE_MEM passed with the platform_device.
To match with this approach we _have to_ recreate that platform_device from what we see on DT. On DT each bus node gets registered as its own platform_device. So in the video-card driver we look for node we know of and put together a platform_device for rmk's driver. We cannot hook DT upon either an lcd node nor dcon node as they might be disabled and the driver will get called multiple times.
Quoted 2 lines
It seems we are moving backwards:
- what about the display controller?
That would be part of probing DT nodes above. I did not take care of that because rmk doesn't support dcon for now.
Quoted 1 line
- how do you clone the lcd 0 output to the port B?
Pass properties on video-card node or even better let dcon driver take care of it when it sees a video-card with more than one crtc.
Quoted 1 line
- what occurs when the si5351 and the tda998x are modules?
Touche, forgot that part. Feel free to add module support to the RFC.
Quoted 2 lines
My driver had the same layout as Russell's when I proposed it to you and when you insisted to handle the 2 LCDs and the 2 ports as one card.
I still insist to handle 2 LCDs and DCON.
Quoted 2 lines
I spent 2 months to have a nice design and you put it to garbage! I am not happy...
I put nothing to garbage. _You_ also agreed to merge with rmk's driver! We can now put in all features we implemented differently _step-by-step_.
Merging the drivers starts with adding support for DT - that is what I provided. You know the HW better than me, why don't you start picking features from your driver and add them in rmk's driver?
Sebastian
Re: [RFC 4/4] DRM: tda998x: add missing include
In reply to Jean-Francois MoineQuoted 7 lines · Jean-Francois Moine
Quoted 4 lines · On Sat, 18 May 2013 19:12:19 +0200 Sebastian…
The RFC sent by Russell King was missing an include for tda998x. This is just a compatible clone to remember Russell to add that later.
Signed-off-by Sebastian Hesselbarth<[email protected]>
...
Quoted 2 lines
These parameters should not be there. It seems to me that the DT is the right place.
True, but if you just read the description above:
"RFC sent by Russell King was missing an include for tda998x".
You want to test the RFC, you need that include.
Sebastian
Re: [RFC 4/4] DRM: tda998x: add missing include
In reply to Jean-Francois MoineQuoted 42 lines · Jean-Francois Moine
Quoted 39 lines · On Sat, 18 May 2013 19:12:19 +0200 Sebastian Hesselbarth…
The RFC sent by Russell King was missing an include for tda998x. This is just a compatible clone to remember Russell to add that later.
Signed-off-by Sebastian Hesselbarth <[email protected]>---
Cc: Russell King <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: Jason Cooper <[email protected]>
Cc: Jean-Francois Moine <[email protected]>--- include/drm/i2c/tda998x.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 include/drm/i2c/tda998x.hinclude/drm/i2c/tda998x.h new file +18
-0@@ -0,0 +1,23 @@ +#ifndef __TDA998X_H__ +#define __TDA998X_H__ + +enum tda998x_audio_format { + AFMT_I2S, + AFMT_SPDIF, +}; + +struct tda998x_encoder_params { + int audio_cfg; + int audio_clk_cfg; + enum tda998x_audio_format audio_format; + int audio_sample_rate; + char audio_frame[6]; + int swap_a, mirr_a; + int swap_b, mirr_b; + int swap_c, mirr_c; + int swap_d, mirr_d;
Quoted 8 lines
include/drm/i2c/tda998x.h line 23
Quoted 5 lines
include/drm/i2c/tda998x.h new file +5
-0+int swap_e, mirr_e; + int swap_f, mirr_f; +}; + +#endif These parameters should not be there. It seems to me that the DT is the right place.
You might not want to directly have a hard DT dependency in tda998x, as the encoder could be used on non-DT platforms. Although a DT to encoder-params helper might be a nice idea for platforms which do have DT.
BR,
-R
Quoted 8 lines
--
Ken ar c'hentañ | ** Breizh ha Linux atav! **
Jef | http://moinejf.free.fr/_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [RFC 2/4] ARM: dove: add video card node for SolidRun CuBox
In reply to Jean-Francois MoineQuoted 8 lines · Jean-Francois Moine
Quoted 6 lines · On Sat, 18 May 2013 19:12:17 +0200 Sebastian…
This adds a video card node required for rmk's
dove_drmdriver. Reg property matches reserved memory region (currently 16M at top of memory), clocks property should carry extclk0 for now.Signed-off-by Sebastian Hesselbarth<[email protected]>---
...
Quoted 6 lines
Quoted 6 lines
arch/arm/boot/dts/dove-cubox.dts +6
-0+ vcard: video-card { + compatible = "marvell,dove-video-card"; + reg =<0x3f000000 0x1000000>; + clocks =<&si5351 0>,<&si5351 0>; + }; + };
...
Quoted 3 lines
Quoted 1 line
+&lcd0 { status = "okay"; };
May you explain a bit more this strange hack?
This "hack" adds the video-card device node that describes the board dependent part of Dove SoC video. Remember, it is a device tree node to match Russel's driver!
You have the video memory passed, the clocks property will vanish later. And you enable lcd0 as you may have noticed that there is nothing connected on lcd1 on the _CuBox_.
But there is on the D2Plug, and that DT description _will_ enable lcd0, lcd1 and dcon.
Maybe, there is a misunderstanding in in the concept of DT here. DT does _not_ describe the driver layout but the HW. And for Linux this basically means, you replace board/SoC dependent init code that register some platform_device with a description in DT.
The actual driver does _not_ need to know about non-DT or DT except that somebody has to parse it and create a platform_device for it. If you only have standard properties like reg and irq, it all gets parsed automagically by DT bus probing. But as you already pointed out, a video card on Dove is a little bit more complex as reg and irq - so I provided a DT parser for rmk's *RFC* driver as *RFC*!
Sebastian
Re: [RFC 4/4] DRM: tda998x: add missing include
In reply to Rob ClarkQuoted 7 lines · On Sat, 18 May 2013 14:23:19 -0400 Rob Clark <[email protected]> wrote:
Quoted 2 lines
These parameters should not be there. It seems to me that the DT is the right place.
You might not want to directly have a hard DT dependency in tda998x, as the encoder could be used on non-DT platforms. Although a DT to encoder-params helper might be a nice idea for platforms which do have DT.
If I correctly understand:
- Russell does not use any DT, so his drm driver should be declared in some cubox-setup code in mach-dove/
- this code should also declare the tda998x
- the drm driver contains/passes parameters to the tda998x
As the connection Dove LCD <-> tda998x is Cubox specific, the question
is: why are'nt the tda998x parameters in the cubox-setup code?
Signature · 7 lines
Ken ar c'hentañ | ** Breizh ha Linux atav! ** Jef | http://moinejf.free.fr/ _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [RFC 4/4] DRM: tda998x: add missing include
Quoted 16 lines · Jean-Francois Moine
Quoted 7 lines · On Sat, 18 May 2013 14:23:19 -0400 Rob Clark <[email protected]> wrote:
Quoted 2 lines
These parameters should not be there. It seems to me that the DT is the right place.
You might not want to directly have a hard DT dependency in tda998x, as the encoder could be used on non-DT platforms. Although a DT to encoder-params helper might be a nice idea for platforms which do have DT.
If I correctly understand:
- Russell does not use any DT, so his drm driver should be declared in some cubox-setup code in mach-dove/
Quoted 6 lines
- this code should also declare the tda998x
- the drm driver contains/passes parameters to the tda998x
As the connection Dove LCD <-> tda998x is Cubox specific, the question
is: why are'nt the tda998x parameters in the cubox-setup code?
ok, maybe I am misunderstanding you. I think the parameters should be filled in by the board file on a non-DT setup. But the part in drivers/gpu/drm/i2c should not pull them directly out of DT, or should have an arrangement like
#ifdef CONFIG_OF
.. pull params out of DT ..
#else
.. use params passed in from via params struct, which is populated in
board file ..
#endif
to accommodate non-DT builds. (Although I think just having a helper to populate 'struct tda998x_encoder_params' from DT seems cleaner.)
BR,
-R
Quoted 3 lines
--
Ken ar c'henta? | ** Breizh ha Linux atav! **
Jef | http://moinejf.free.fr/
Re: [RFC 3/4] DRM: add OF support for Dove DRM driver
In reply to Sebastian HesselbarthQuoted 7 lines · On Sat, 18 May 2013 20:20:00 +0200 Sebastian Hesselbarth…
I put nothing to garbage. _You_ also agreed to merge with rmk's driver! We can now put in all features we implemented differently _step-by-step_.
Merging the drivers starts with adding support for DT - that is what I provided. You know the HW better than me, why don't you start picking features from your driver and add them in rmk's driver?
The general hardware code of both drivers is close enough for merging may be done starting from anyone. But the general layout is not:
- my driver is DT driven and has one card with 2 CTRC's and 2 connectors.
- Russell's is non-DT, so, with some extra code I am not aware of, with any number of cards each one with one CRTC and one connector (no, I tried it, you cannot clone a connector of one card to the connector of another card).
So, for me, merging means enhance my code from Russell's, but I will not go to a non-DT kernel.
Signature · 7 lines
Ken ar c'hentañ | ** Breizh ha Linux atav! ** Jef | http://moinejf.free.fr/ _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [RFC 4/4] DRM: tda998x: add missing include
In reply to Jean-Francois MoineQuoted 11 lines · Jean-Francois Moine
Quoted 7 lines · On Sat, 18 May 2013 14:23:19 -0400 Rob Clark<[email protected]> wrote:
Quoted 2 lines
These parameters should not be there. It seems to me that the DT is the right place.
You might not want to directly have a hard DT dependency in tda998x, as the encoder could be used on non-DT platforms. Although a DT to encoder-params helper might be a nice idea for platforms which do have DT.
Quoted 4 lines
If I correctly understand:
- Russell does not use any DT, so his drm driver should be declared in some cubox-setup code in mach-dove/
No. The _device_ is declared in some cubox-setup but the _driver_ goes into drivers/gpu/drm. Reading vendor provided kernel code may be misleading as they often just put all stuff in arch/arm/mach-something.
Quoted 1 line
- this code should also declare the tda998x
The device for tda998x yes, but not the driver. Anyway, Russel decided to have tda998x probed by his drm_driver.
Quoted 4 lines
- the drm driver contains/passes parameters to the tda998x
As the connection Dove LCD<-> tda998x is Cubox specific, the question
is: why are'nt the tda998x parameters in the cubox-setup code?
The connection of Dove LCD and tda998x is _not_ Cubox specific, it is also on the D2Plug. To be precise, even "Dove LCD" is not Dove specific as you can find the very same controller on other Marvell SoCs with little differences.
So in the end, we will have a DT node for the HW controllers found in Dove SoCs, a node for TDA998x, and a node for the video card, i.e. _how_ lcd controllers, external encoders, clocks, maybe audio, ... are hooked up on that specific board.
There is so much to take care of like pixel format on lcd pins driving an external encoder (_not_ only tda998x), what gpio pin is connected to TDA interrupt line, one or two lcds, ...
The corresponding drivers _will_ take care of it .. but in the future. All I try to make sure is that driver architecture does not prevent us from e.g. having two lcds plus dcon later on. Or allows to reuse dove-drm on pxa where only one lcd but no dcon is available.
Sebastian
Re: [RFC 4/4] DRM: tda998x: add missing include
Quoted 2 lines · Sebastian Hesselbarth
The device for tda998x yes, but not the driver. Anyway, Russel decided to have tda998x probed by his
drm_driver.
For the simple reason that _that_ is how DRM slave encoders work. Sometimes, reading the code of the subsystem you're using is well worth the effort.
If Jean-Francois would like to read drm_encoder_slave.c, then it will be found that in order to use the TDA998x driver, which is itself a DRM slave encoder, you must use drm_i2c_encoder_init(). In order to use that, you must provide the I2C adapter structure, and a board info structure.
If you don't want to do that, your options are:
(a) you don't use the existing TDA998x DRM slave encoder, and instead write your own TDA998x driver, which will likely be justifyable rejected, or
(b) you propose a new DRM interface to allow DRM components to be registered independently, without reference to a core drm_device structure.
Quoted 4 lines
The connection of Dove LCD and tda998x is _not_ Cubox specific, it is also on the D2Plug. To be precise, even "Dove LCD" is not Dove specific as you can find the very same controller on other Marvell SoCs with little differences.
Well, to spoil the argument a little, actually, the interconnection between the two is in no way "standardized". There's many different ways to wire the two chips together and have it work - because the TDA998x chips have a set of input muxes and swaps which allow you to connect the red, green, blue high/low nibbles in various ways and still have a correctly working system. The TDA998x connectivity is _highly_ configuable.
So, just because one board connects LCD_D0 (red bit 0) to a particular pin on the TDA998x does not mean that another board does it that way too.
So Jean-Francois is quite correct that this data needs to be provided by the board in some manner. The question is - how to do that sensibly.
One possible stop-gap solution is to provide a default set which just happens to match the cubox, and allow OF to override it. :)
Quoted 3 lines
There is so much to take care of like pixel format on lcd pins driving an external encoder (_not_ only tda998x), what gpio pin is connected to TDA interrupt line, one or two lcds, ...
Luckily, drivers/gpu/drm/i2c/tda998x.c does not make use of the IRQ signal at present - it's fairly basic and it currently operates by polling. Eventually, this could change of course. :)
I think people need to keep a sense of perspective here: this is all entirely "new" stuff which is still being actively developed. It is not fully polished. We've not had a true open source TDA998x driver before 3.9 (that's when it was introduced.) It has teething problems at the moment, but I'm working with the authors to resolve these issues. I'm also still working on the DRM driver.
For example, I've been playing with the RGB888 cursor support today, which seems to be suffering from a one pixel error in the hotspot location. I've not got to the bottom of it, but that kind of error _is_ important to understand and resolve, because it means that things like drawing programmes become unusable.
What I'm starting to suspect is a bug in the X server causing this and not either my DRM driver or Xorg driver.
Re: [RFC 3/4] DRM: add OF support for Dove DRM driver
In reply to Jean-Francois MoineQuoted 4 lines · Jean-Francois Moine
It seems we are moving backwards:
- what about the display controller?
- how do you clone the lcd 0 output to the port B?
- what occurs when the si5351 and the tda998x are modules?
I've no idea why you keep bringing that last point up. I've already told you what happens when the SI5351 is a module. It is already not a problem as I have already evidenced by my boot log. So please get that and stop repeating this same point which I've already answered, or I will start ranting at you and we will have a massive falling out.
As for cloning output to the VGA port, that's just a matter of dealing with the display controller. That's _not_ difficult.
Quoted 2 lines
My driver had the same layout as Russell's when I proposed it to you and when you insisted to handle the 2 LCDs and the 2 ports as one card.
This seems to be a misrepresentation. So what you're saying is that your driver originally handled the two LCDs as two separate cards.
That is _not_ the same as my driver. My driver handles the two LCDs as two separate CRTs of the same DRM device. This allows X to drive the two CRTs together in any manner it desires depending on the capabilities of the "connectors" associated with each CRTC and the user preferences.
Quoted 2 lines
I spent 2 months to have a nice design and you put it to garbage! I am not happy...
Stop that right now. If you want to start whinging about the amount of time you've spent on this, then I can tell you now that if you have only spent two months on this, you are a total newbie to this and your effort is utterly insignificant compared to mine. And you *have* touched a nerve here by making that statement.
Re: [RFC 4/4] DRM: tda998x: add missing include
In reply to Russell King - ARM LinuxQuoted 7 lines · Russell King - ARM Linux
Quoted 2 lines · Sebastian Hesselbarth
The device for tda998x yes, but not the driver. Anyway, Russel decided to have tda998x probed by his
drm_driver.For the simple reason that _that_ is how DRM slave encoders work. Sometimes, reading the code of the subsystem you're using is well worth the effort.
I agree and add that the probing itself doesn't prevent you from using DT for tda driver at all. You can still have an marvell,external-slave property pointing to the phandle of tda node. With that you get the adapter and i2c slave address for what is currently called dove_tda19989.c and may become e.g. dove_ext_i2c.c. In tda998x_drv you find the node and get all properties for input config or interrupt gpio.
I have done that in the drivers before, but DT node parsing here is _added_ to the driver as it can be used on other non-DT platforms as well.
Quoted 17 lines
Quoted 4 lines
The connection of Dove LCD and tda998x is _not_ Cubox specific, it is also on the D2Plug. To be precise, even "Dove LCD" is not Dove specific as you can find the very same controller on other Marvell SoCs with little differences.
Well, to spoil the argument a little, actually, the interconnection between the two is in no way "standardized". There's many different ways to wire the two chips together and have it work - because the TDA998x chips have a set of input muxes and swaps which allow you to connect the red, green, blue high/low nibbles in various ways and still have a correctly working system. The TDA998x connectivity is _highly_ configuable.
So, just because one board connects
LCD_D0(red bit 0) to a particular pin on the TDA998x does not mean that another board does it that way too.
Quoted 5 lines
So Jean-Francois is quite correct that this data needs to be provided by the board in some manner. The question is - how to do that sensibly.
One possible stop-gap solution is to provide a default set which just happens to match the cubox, and allow OF to override it. :)
While I agree, Rob may have a different view on that for tda998x ;)
Quoted 7 lines
Quoted 3 lines
There is so much to take care of like pixel format on lcd pins driving an external encoder (_not_ only tda998x), what gpio pin is connected to TDA interrupt line, one or two lcds, ...
Luckily,
drivers/gpu/drm/i2c/tda998x.cdoes not make use of the IRQ signal at present - it's fairly basic and it currently operates by polling. Eventually, this could change of course. :)
Again, that is in the driver Jean-Francois has available. Make sure irq handler runs in a separate thread from get_edid and hpd and you will be interrupted on hpd. Having said, that should finally lead to the slave encoder setting .connector_type and .polled as this is where you know it.
Sebastian
Re: [RFC 4/4] DRM: tda998x: add missing include
In reply to Sebastian HesselbarthQuoted 4 lines · On Sat, 18 May 2013 21:30:09 +0200 Sebastian Hesselbarth…
So in the end, we will have a DT node for the HW controllers found in Dove SoCs, a node for TDA998x, and a node for the video card, i.e. _how_ lcd controllers, external encoders, clocks, maybe audio, ... are hooked up on that specific board.
Here is my dove-cubox.dts. What is wrong with it?
/dts-v1/;
/include/ "dove.dtsi"
/ {
model = "SolidRun CuBox";
compatible = "solidrun,cubox", "marvell,dove";
memory {
device_type = "memory";
reg = <0x00000000 0x40000000>;
};
chosen {
bootargs = "console=ttyS0,115200n8 earlyprintk";
};
leds {
compatible = "gpio-leds";
pinctrl-0 = <&pmx_gpio_18>;
pinctrl-names = "default";
power {
label = "Power";
gpios = <&gpio0 18 1>;
linux,default-trigger = "default-on";
};
};
regulators {
compatible = "simple-bus";
#address-cells = <1>;
#size-cells = <0>;
usb_power: regulator@1 {
compatible = "regulator-fixed";
reg = <1>;
regulator-name = "USB Power";
regulator-min-microvolt = <5000000>;
regulator-max-microvolt = <5000000>;
enable-active-high;
regulator-always-on;
regulator-boot-on;
gpio = <&gpio0 1 0>;
};
};
clocks {
/* 25MHz reference crystal */
ref25: oscillator {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <25000000>;
};
lcdclk: fixed-clock {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <400000000>;
};
};
audio {
compatible = "marvell,kirkwood-spdif-audio";
id = <1>;
};
video {
compatible = "marvell,dove-video";
};
};&uart0 { status = "okay"; };
&sata0 { status = "okay"; };
&i2c0 {
status = "okay";
clock-frequency = <100000>;
si5351: clock-generator {
compatible = "silabs,si5351a-msop";
reg = <0x60>;
#address-cells = <1>;
#size-cells = <0>;
#clock-cells = <1>;
/* connect xtal input to 25MHz reference */
clocks = <&ref25>;
/* connect xtal input as source of pll0 and pll1 */
silabs,pll-source = <0 0>, <1 0>;
clkout0 {
reg = <0>;
silabs,drive-strength = <8>;
silabs,multisynth-source = <0>;
silabs,clock-source = <0>;
silabs,pll-master;
};
clkout1 {
reg = <1>;
silabs,drive-strength = <8>;
silabs,multisynth-source = <1>;
silabs,clock-source = <0>;
silabs,pll-master;
};
clkout2 {
reg = <2>;
silabs,multisynth-source = <1>;
silabs,clock-source = <0>;
};
};
tda998x: hdmi-encoder {
compatible = "nxp,tda998x";
reg = <0x70>;
interrupt-parent = <&gpio0>;
interrupts = <27 2>; /* falling edge */
};
};&sdio0 {
status = "okay";
/* sdio0 card detect is connected to wrong pin on CuBox */
cd-gpios = <&gpio0 12 1>;
};&spi0 {
status = "okay";
/* spi0.0: 4M Flash Winbond W25Q32BV */
spi-flash@0 {
compatible = "st,w25q32";
spi-max-frequency = <20000000>;
reg = <0>;
};
};&pinctrl {
pinctrl-0 = <&pmx_gpio_1 &pmx_gpio_12 &pmx_gpio_13 &pmx_gpio_camera>;
pinctrl-names = "default";
pmx_gpio_1: pmx-gpio-1 {
marvell,pins = "mpp1";
marvell,function = "gpio";
};
pmx_gpio_12: pmx-gpio-12 {
marvell,pins = "mpp12";
marvell,function = "gpio";
};/* kirkwood i2s */
pmx_gpio_13: pmx-gpio-13 {
marvell,pins = "mpp13";
marvell,function = "gpio";
};
pmx_gpio_18: pmx-gpio-18 {
marvell,pins = "mpp18";
marvell,function = "gpio";
};
/* nxp HDMI irq on pin 27 */
pmx_gpio_camera: pmx-gpio-camera {
marvell,pins = "mpp_camera";
marvell,function = "gpio";
};
};&mdio { status = "okay"; };
ðernet { status = "okay"; };
&lcd0 {
status = "okay";
clocks = <&core_clk 3>, <0>, <&lcdclk>, <&si5351 0>;
marvell,port-type = <11>; /* HDMIA */
marvell,external-encoder = <&tda998x>;
};&i2s1 { status = "okay"; };
/* --- test (not cubox) ---- *
&dcon { status = "okay"; };
&lcd1 {
status = "okay";
clocks = <&core_clk 3>, <0>, <&lcdclk>, <0>;
marvell,port-type = <1>;
display-timings {
mode {
hactive = <1920>;
vactive = <1080>;
hfront-porch = <88>;
hsync-len = <44>;
hback-porch = <148>;
vfront-porch = <4>;
vsync-len = <5>;
vback-porch = <36>;
clock = <148500>;
};
};
};* ---- */
Signature · 7 lines
Ken ar c'hentañ | ** Breizh ha Linux atav! ** Jef | http://moinejf.free.fr/ _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [RFC 4/4] DRM: tda998x: add missing include
Quoted 8 lines · Jean-Francois Moine
Quoted 4 lines · On Sat, 18 May 2013 21:30:09 +0200 Sebastian…
So in the end, we will have a DT node for the HW controllers found in Dove SoCs, a node for TDA998x, and a node for the video card, i.e. _how_ lcd controllers, external encoders, clocks, maybe audio, ... are hooked up on that specific board.
Here is my
dove-cubox.dts. What is wrong with it?
Oh come on, seriously?
There is _nothing_ wrong with it, it already reflects what I told you would be required for generic Dove SoC board video.
Quoted 3 lines
video {
compatible = "marvell,dove-video";
};As you may have noticed, the RFC node I sent yesterday. Is in _no_ way different from a functional point of view. I added a video-memory property, I renamed the compatible string. And I moved clocks property to the video card *but* as I said in the RFC description:
"This adds a video card node required for rmk's dove_drm driver. Reg
property matches reserved memory region (currently 16M at top of memory), clocks property should carry extclk0 for now."
It is a node *required for rmk's dove_drm driver* for you to _test_ that very driver.
Quoted 6 lines
&lcd0 {
status = "okay";
clocks =<&core_clk 3>,<0>,<&lcdclk>,<&si5351 0>;
marvell,port-type =<11>; /* HDMIA */
marvell,external-encoder =<&tda998x>;
};Again, there is no DT support in *rmk's driver*! I didn't add those to the RFC node. I provided a DT node to *test* rmk driver. While you were busy with complaining about things we already answered, I did test the driver on both Cubox and D2Plug. Now I can start with looking into rmk's driver and _suggest_ to fix this or that.
Quoted 12 lines
/* --- test (not cubox) ---- *
&dcon { status = "okay"; };&lcd1 { status = "okay"; clocks =<&core_clk 3>,<0>,<&lcdclk>,<0>; marvell,port-type =<1>; display-timings { mode { hactive =<1920>; vactive =<1080>; hfront-porch =<88>;
Quoted 8 lines
hsync-len =<44>; hback-porch =<148>; vfront-porch =<4>; vsync-len =<5>; vback-porch =<36>; clock =<148500>; }; };
I would be surprised if, lcd1 will ever be capable of driving 1080p60 on a *VGA port*!
Seriously, start _reading_ what we say. I want all those features I already told you for your driver, in mainline driver too. All I told you was to prevent you from doing dirty little Cubox specific hacks that I would have to remove for e.g. D2Plug.
*But* if you ask me if we should take Russell's or your driver as a basis, the answer is Russell's. Colon.
Sebastian
Quoted 4 lines · Jean-Francois Moine
Maybe I did not explain correctly: the colored cursor maybe RGB888 + transparency (64x64) or full ARGB (64x32 or 32x64). I coded the first case. And, yes, I better like a hardware cursor: it asks for less computation, and I get it immediately at graphic starting time!
Having looked at this now, using the RGB+transparency is less than ideal because we're having to reduce an alpha channel down to a simple on/off transparency. X cursors really are alphablended components!
So, the options here are:
(a) use "software" rendered cursor
+ correct and expected cursor size
+ correct rendering
+ possible to use the GPU (I believe mine does)
- maybe time consuming as it has to be removed/replaced on the screen
(b) use RGB+transparency for 64x64 hardware cursor
+ correct and expected cursor size
+ does not have to be removed/replaced when screen contents change
- incorrect rendering due to reducing the alpha channel to a simple on/off transparency mask
- has to be reloaded when the pointer is close to the edges of the screen which is CPU intensive
- cursor image data passed into DRM is required to be ARGB (I've discussed this with David Airlie last night.) This means we have to do translation to RGB+T in the kernel which is *not* nice.
(c) use ARGB 32x64 or 64x32 hardware cursor
+ does not have to be removed/replaced when screen contents change
+ correct rendering of cursor
- unexpected cursor size; user clients do not expect to be restricted to 32 rows or 32 lines of cursor
- can only select maximum cursor size on initialization of hardware cursor; can't dynamically switch between 32x64 and 64x32 sizes
- has to be reloaded when the pointer is close to the edges of the screen which is CPU intensive
While I would like to have hardware cursor support, I don't think it's worth the effort. The one which tips it for me is the need to reload the cursor near the edges - note the restriction in the documentation that the cursor position + cursor size can't be outside the active size. Also, cursors generally have 7 or so transparent pixels to the left of them (which of course changes depending on the cursor shape.)
It's also less CPU intensive to (probably) allow the GPU to render it than it is for the CPU to deal with these hardware restrictions.
I would've liked to see hardware cursor support, but I think what I'm going to be doing is stripping the cursor code out of the main driver into a separate optional patch which will ultimately be dropped.
Re: [RFC 3/8] drm/i2c: nxp-tda998x: ensure VIP output mux is properly set
In reply to Jean-Francois MoineQuoted 31 lines · Jean-Francois Moine
Quoted 28 lines · On Thu, 16 May 2013 20:26:18 +0100 Russell King <[email protected]>…
When switching between various drivers for this device, it's possible that some critical registers are left containing values which affect the device operation. One such case encountered is the VIP output mux register. This defaults to
0x24on powerup, but other drivers may set this to0x12. This results in incorrect colours.Fix this by ensuring that the register is always set to the power on default setting.
Signed-off-by Russell King <[email protected]>--- drivers/gpu/drm/i2c/tda998x_drv.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)drivers/gpu/drm/i2c/tda998x_drv.c +1
-0@@ -110,6 +110,7 @@ struct tda998x_priv {#define REG_VIP_CNTRL_5 REG(0x00, 0x25)/* write */ # define VIP_CNTRL_5_CKCASE (1 << 0)# define VIP_CNTRL_5_SP_CNT (x) (((x) & 3) << 1) +#define REG_MUX_VP_VIP_OUT REG(0x00, 0x27)/* read/write */ #define REG_MAT_CONTRL REG(0x00, 0x80)/* write */ # define MAT_CONTRL_MAT_SC (x) (((x) & 3) << 0)# define MAT_CONTRL_MAT_BP (1 << 2)@@ -438,6 +439,8 @@ tda998x_encoder_dpms(struct drm_encoder *encoder, int mode)
Quoted 10 lines
drivers/gpu/drm/i2c/tda998x_drv.c tda998x_encoder_dpms(struct drm_encoder *encoder, int mode) · line 446
Quoted 7 lines
drivers/gpu/drm/i2c/tda998x_drv.c +2
-0switch (mode) {case DRM_MODE_DPMS_ON : +/* Write the default value MUX register */ +reg_write (encoder,REG_MUX_VP_VIP_OUT ,0x24 );/* enable audio and video ports */ reg_write (encoder,REG_ENA_AP ,0xff );reg_write (encoder,REG_ENA_VP_0 ,0xff );This register is never touched. Should not this setting better go at reset time (in
tda998x_reset)?
Yes, you're right, it could be done there without any additional side effects. I've just moved it there.
Quoted 6 lines · Jean-Francois Moine
I quickly compared your dove drm driver and ours (Sebastian and me):
- CMA helper
You don't use
DRM_KMS_CMA_HELPERandDRM_GEM_CMA_HELPERwhich would simplify some code.
Looking at the CMA helper code in DRM, it makes some fundamental errors:
1. It assumes the returned DMA address is a physical address. This is not necessarily the case (there are a number of ARM platforms where this is most definitely not true.) So:
cma_obj->vaddr = dma_alloc_writecombine(drm->dev, size,
&cma_obj->paddr, GFP_KERNEL | __GFP_NOWARN);
...
ret = remap_pfn_range(vma, vma->vm_start, cma_obj->paddr >> PAGE_SHIFT,
vma->vm_end - vma->vm_start, vma->vm_page_prot);is extremely broken.
2. If you use the CMA helper, then all your GEM objects must be CMA objects. You can't combine different types of objects (eg, SHM-backed objects) with CMA objects. This will be a massive performance regression with GPUs which can handle scatter-gathered SHM objects such as the Vivante GPU on the Armada 510.
So, for me, the last point especially is a very strong argument not to use the DRM CMA helper. Yes, I could switch to using the DMA coherent/ writecombine allocation API and thus make use of CMA, and that's something I will be looking at.
Re: [RFC 4/4] DRM: tda998x: add missing include
In reply to Sebastian HesselbarthQuoted 21 lines · On Sun, 19 May 2013 10:30:00 +0200 Sebastian Hesselbarth…
Quoted 12 lines
/* --- test (not cubox) ---- *
&dcon { status = "okay"; };&lcd1 { status = "okay"; clocks =<&core_clk 3>,<0>,<&lcdclk>,<0>; marvell,port-type =<1>; display-timings { mode { hactive =<1920>; vactive =<1080>; hfront-porch =<88>;Quoted 8 lines
hsync-len =<44>; hback-porch =<148>; vfront-porch =<4>; vsync-len =<5>; vback-porch =<36>; clock =<148500>; }; };
Quoted 2 lines
I would be surprised if, lcd1 will ever be capable of driving 1080p60 on a *VGA port*!
As you may see, this sequence is preceded by an open comment: "test".
Now, as the port B of the display controller is only VGA (this is checked in my driver), as there is no VGA connector on the Cubox, as there is no VGA DAC code in my driver, and as I had to test the display controller, I:
- defined the port B as VGA,
- set the timings of the mode I use for my HDMI display.
This does not mean the example must be used in the real word. It is just a working example for test purpose.
Quoted 4 lines
Seriously, start _reading_ what we say. I want all those features I already told you for your driver, in mainline driver too. All I told you was to prevent you from doing dirty little Cubox specific hacks that I would have to remove for e.g. D2Plug.
There is _NO_ Cubox specific stuff in my driver (I don't even use any cubox-setup as Russell) and it should work without any change (except the DT) in your D2plug. Remember, all my drm driver work is in
http://moinejf.free.fr/cubox/ as a big kernel patch (I will add the
I2C: mv64xxx which work fine - thanks Russell).
Quoted 2 lines
*But* if you ask me if we should take Russell's or your driver as a basis, the answer is Russell's. Colon.
OK. Do what you want. My driver works fine enough for my usage:
software development. For video, my ISP gives us for free a Atom based multimedia player with a Blue-Ray reader, and I have a AMD64 double core on my family TV set for internet video (it will be a long time till there will be VP8 decoding with vMeta). The only interest I see in the Cubox is its low power consumption.
Now, I will switch back to my favorite long-distance development...
See you.
Signature · 7 lines
Ken ar c'hentañ | ** Breizh ha Linux atav! ** Jef | http://moinejf.free.fr/ _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [RFC 3/4] DRM: add OF support for Dove DRM driver
In reply to Jean-Francois MoineQuoted 7 lines · Jean-Francois Moine
The general hardware code of both drivers is close enough for merging may be done starting from anyone. But the general layout is not:
- my driver is DT driven and has one card with 2 CTRC's and 2 connectors.
- Russell's is non-DT, so, with some extra code I am not aware of, with any number of cards each one with one CRTC and one connector (no, I
Utter shit, and I've told you before. I'm not going to repeat it again, and I warned you that we would have a falling out. As you seem to be immune to my comments provided in a sane manner, I'm now just going to ignore you in the future because you're clearly not bothering to read anything I'm telling you. That makes further discussion with you utterly pointless.
Quoted 5 lines
tried it, you cannot clone a connector of one card to the connector of another card).
So, for me, merging means enhance my code from Russell's, but I will not go to a non-DT kernel.
You seem to see DT setups vs non-DT setups as two entirely separate things. They are not. We have plenty of drivers which work in both setups just fine.
So really all of your points above are utter trash to me - really.
As to illustrate the point, my TDA19988 backend is now _just_ a slave encoder backend, it has nothing TDA19988 specific, nor does it have anything cubox specific there; the cubox specific part has been moved up into dove_drv.c as pure data, and that data can be constructed either from platform data or from OF properties parsed by dove_drv.c.
But why did I just bother to type that. You're just going to ignore it and keep repeating your same old claptrap.
Quoted 27 lines · Russell King - ARM Linux
Quoted 4 lines · Jean-Francois Moine
Maybe I did not explain correctly: the colored cursor maybe RGB888 + transparency (64x64) or full ARGB (64x32 or 32x64). I coded the first case. And, yes, I better like a hardware cursor: it asks for less computation, and I get it immediately at graphic starting time!
Having looked at this now, using the RGB+transparency is less than ideal because we're having to reduce an alpha channel down to a simple on/off transparency. X cursors really are alphablended components!
So, the options here are:
(a) use "software" rendered cursor
+ correct and expected cursor size
+ correct rendering
+ possible to use the GPU (I believe mine does)
- maybe time consuming as it has to be removed/replaced on the screen
(b) use RGB+transparency for 64x64 hardware cursor
+ correct and expected cursor size
+ does not have to be removed/replaced when screen contents change
- incorrect rendering due to reducing the alpha channel to a simple on/off transparency mask
- has to be reloaded when the pointer is close to the edges of the screen which is CPU intensive
- cursor image data passed into DRM is required to be ARGB (I've discussed this with David Airlie last night.) This means we have to do translation to RGB+T in the kernel which is *not* nice.
(c) use ARGB 32x64 or 64x32 hardware cursor
Quoted 8 lines
+ does not have to be removed/replaced when screen contents change
+ correct rendering of cursor
- unexpected cursor size; user clients do not expect to be restricted to 32 rows or 32 lines of cursor
- can only select maximum cursor size on initialization of hardware cursor; can't dynamically switch between 32x64 and 64x32 sizes
- has to be reloaded when the pointer is close to the edges of the screen which is CPU intensive
You can tell the xserver what size cursor you support when you call xf86_cursors_init() in the ddx. Just expose a 32x64 or 64x32 ARGB cursor. Most apps don't use a 64x64 cursor anyway. I've used hardware with non-64x64 cursors and haven't run into any problems yet.
Alex
Quoted 4 lines · Alex Deucher
You can tell the xserver what size cursor you support when you call
xf86_cursors_init()in the ddx. Just expose a 32x64 or 64x32 ARGB cursor. Most apps don't use a 64x64 cursor anyway. I've used hardware with non-64x64 cursors and haven't run into any problems yet.
I guess the xf86 backend will fall back to software cursors if it gets a cursor larger than the hardware supports, so maybe 64x32 will be fine.
However, my comments concerning the less-than-64x64 size come from David Airlie who said "X and userside programs expect 64x64 to work. so its possibly pointless supporting anything less, as in you'd write code but nobody would end up using it".
Note also that the generic DRM KMS code assumes cursor support at 64x64, and there's no generic way for a driver at present (that I know of) to inform it of anything different.
Quoted 10 lines · Russell King - ARM Linux
Quoted 4 lines · Alex Deucher
You can tell the xserver what size cursor you support when you call
xf86_cursors_init()in the ddx. Just expose a 32x64 or 64x32 ARGB cursor. Most apps don't use a 64x64 cursor anyway. I've used hardware with non-64x64 cursors and haven't run into any problems yet.I guess the xf86 backend will fall back to software cursors if it gets a cursor larger than the hardware supports, so maybe 64x32 will be fine.
Quoted 8 lines
However, my comments concerning the less-than-64x64 size come from David Airlie who said "X and userside programs expect 64x64 to work. so its possibly pointless supporting anything less, as in you'd write code but nobody would end up using it".
Note also that the generic DRM KMS code assumes cursor support at 64x64, and there's no generic way for a driver at present (that I know of) to inform it of anything different.
It shouldn't be too hard to add a new cap for querying the cursor size to the drm cap interface.
Alex
Quoted 6 lines · On Mon, 20 May 2013 16:23:33 -0400 Alex Deucher <[email protected]> wrote:
Quoted 3 lines
Note also that the generic DRM KMS code assumes cursor support at 64x64, and there's no generic way for a driver at present (that I know of) to inform it of anything different.
It shouldn't be too hard to add a new cap for querying the cursor size to the drm cap interface.
There was already a patch request for that, but the functions were surely useless.
Otherwise, you may do a search on "largest cursor:" (xdpyinfo output). The results are surprising..
Signature · 7 lines
Ken ar c'hentañ | ** Breizh ha Linux atav! ** Jef | http://moinejf.free.fr/ _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [RFC 6/8] drm/i2c: nxp-tda998x: add video and audio input configuration
In reply to Russell KingQuoted 184 lines · Russell King
Signed-off-by Russell King <[email protected]>--- drivers/gpu/drm/i2c/tda998x_drv.c | 308 ++++++++++++++++++++++++++++++++++++- 1 files changed, 301 insertions(+), 7 deletions(-)drivers/gpu/drm/i2c/tda998x_drv.c +103
-1@@ -23,7 +23,7 @@#include <drm/drm_crtc_helper.h> #include <drm/drm_encoder_slave.h> #include <drm/drm_edid.h> - +#include <drm/i2c/tda998x.h> #define DBG (fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)@@ -32,9 +32,11 @@ struct tda998x_priv {uint16_t rev;uint8_t current_page;int dpms; +bool is_hdmi_sink;u8 vip_cntrl_0;u8 vip_cntrl_1;u8 vip_cntrl_2; +struct tda998x_encoder_params params; };#define to_tda998x_priv (x) ((struct tda998x_priv *)to_encoder_slave(x)->slave_priv)@@ -71,10 +73,13 @@ struct tda998x_priv {# define I2C_MASTER_DIS_MM (1 << 0)# define I2C_MASTER_DIS_FILT (1 << 1)# define I2C_MASTER_APP_STRT_LAT (1 << 2) +#define REG_FEAT_POWERDOWN REG(0x00, 0x0e)/* read/write */ +# define FEAT_POWERDOWN_SPDIF (1 << 3)#define REG_INT_FLAGS_0 REG(0x00, 0x0f)/* read/write */ #define REG_INT_FLAGS_1 REG(0x00, 0x10)/* read/write */ #define REG_INT_FLAGS_2 REG(0x00, 0x11)/* read/write */ # define INT_FLAGS_2_EDID_BLK_RD (1 << 1) +#define REG_ENA_ACLK REG(0x00, 0x16)/* read/write */ #define REG_ENA_VP_0 REG(0x00, 0x18)/* read/write */ #define REG_ENA_VP_1 REG(0x00, 0x19)/* read/write */ #define REG_ENA_VP_2 REG(0x00, 0x1a)/* read/write */ @@ -113,6 +118,7 @@ struct tda998x_priv {#define REG_VIP_CNTRL_5 REG(0x00, 0x25)/* write */ # define VIP_CNTRL_5_CKCASE (1 << 0)# define VIP_CNTRL_5_SP_CNT (x) (((x) & 3) << 1) +#define REG_MUX_AP REG(0x00, 0x26)/* read/write */ #define REG_MUX_VP_VIP_OUT REG(0x00, 0x27)/* read/write */ #define REG_MAT_CONTRL REG(0x00, 0x80)/* write */ # define MAT_CONTRL_MAT_SC (x) (((x) & 3) << 0)@@ -175,6 +181,12 @@ struct tda998x_priv {# define HVF_CNTRL_1_PAD (x) (((x) & 3) << 4)# define HVF_CNTRL_1_SEMI_PLANAR (1 << 6)#define REG_RPT_CNTRL REG(0x00, 0xf0)/* write */ +#define REG_I2S_FORMAT REG(0x00, 0xfc)/* read/write */ +# define I2S_FORMAT (x) (((x) & 3) << 0) +#define REG_AIP_CLKSEL REG(0x00, 0xfd)/* write */ +# define AIP_CLKSEL_FS (x) (((x) & 3) << 0) +# define AIP_CLKSEL_CLK_POL (x) (((x) & 1) << 2) +# define AIP_CLKSEL_AIP (x) (((x) & 7) << 3)/* Page 02h: PLL settings */ @@ -216,6 +228,11 @@ struct tda998x_priv {/* Page 10h: information frames and packets */ +#define REG_IF1_HB0 REG(0x10, 0x20)/* read/write */ +#define REG_IF2_HB0 REG(0x10, 0x40)/* read/write */ +#define REG_IF3_HB0 REG(0x10, 0x60)/* read/write */ +#define REG_IF4_HB0 REG(0x10, 0x80)/* read/write */ +#define REG_IF5_HB0 REG(0x10, 0xa0)/* read/write */ /* Page 11h: audio settings and content info packets */ @@ -225,10 +242,33 @@ struct tda998x_priv {# define AIP_CNTRL_0_LAYOUT (1 << 2)# define AIP_CNTRL_0_ACR_MAN (1 << 5)# define AIP_CNTRL_0_RST_CTS (1 << 6) +#define REG_CA_I2S REG(0x11, 0x01)/* read/write */ +# define CA_I2S_CA_I2S (x) (((x) & 31) << 0) +# define CA_I2S_HBR_CHSTAT (1 << 6) +#define REG_LATENCY_RD REG(0x11, 0x04)/* read/write */ +#define REG_ACR_CTS_0 REG(0x11, 0x05)/* read/write */ +#define REG_ACR_CTS_1 REG(0x11, 0x06)/* read/write */ +#define REG_ACR_CTS_2 REG(0x11, 0x07)/* read/write */ +#define REG_ACR_N_0 REG(0x11, 0x08)/* read/write */ +#define REG_ACR_N_1 REG(0x11, 0x09)/* read/write */ +#define REG_ACR_N_2 REG(0x11, 0x0a)/* read/write */ +#define REG_CTS_N REG(0x11, 0x0c)/* read/write */ +# define CTS_N_K (x) (((x) & 7) << 0) +# define CTS_N_M (x) (((x) & 3) << 4)#define REG_ENC_CNTRL REG(0x11, 0x0d)/* read/write */ # define ENC_CNTRL_RST_ENC (1 << 0)# define ENC_CNTRL_RST_SEL (1 << 1)# define ENC_CNTRL_CTL_CODE (x) (((x) & 3) << 2) +#define REG_DIP_FLAGS REG(0x11, 0x0e)/* read/write */ +# define DIP_FLAGS_ACR (1 << 0) +# define DIP_FLAGS_GC (1 << 1) +#define REG_DIP_IF_FLAGS REG(0x11, 0x0f)/* read/write */ +# define DIP_IF_FLAGS_IF1 (1 << 1) +# define DIP_IF_FLAGS_IF2 (1 << 2) +# define DIP_IF_FLAGS_IF3 (1 << 3) +# define DIP_IF_FLAGS_IF4 (1 << 4) +# define DIP_IF_FLAGS_IF5 (1 << 5) +#define REG_CH_STAT_B (x) REG(0x11, 0x14 + (x))/* read/write */ /* Page 12h: HDCP and OTP */ @@ -344,6 +384,23 @@ reg_read_range(struct drm_encoder *encoder, uint16_t reg, char *buf, int cnt)return ret; } +static void +reg_write_range (struct drm_encoder *encoder,uint16_t reg,uint8_t *p,int cnt) +{ +struct i2c_client *client =drm_i2c_encoder_get_client (encoder); +uint8_t buf[cnt+1 ]; +int ret; + + buf[0 ] =REG2ADDR (reg); +memcpy (&buf[1 ], p, cnt); + +set_page (encoder, reg); + + ret =i2c_master_send (client, buf, cnt +1 ); +if (ret <0 ) +dev_err (&client->dev,"Error %d writing to 0x%x\n" , ret, reg); +} +static uint8_t reg_read (struct drm_encoder *encoder,uint16_t reg) {@@ -421,11 +478,192 @@ tda998x_reset(struct drm_encoder *encoder)reg_write (encoder,REG_PLL_SCG2 ,0x10 ); } +static uint8_t tda998x_cksum (uint8_t *buf,size_t bytes) +{ +uint8_t sum =0 ; + +while (bytes--) + sum += *buf++; +return (255 - sum) +1 ; +} + +#define HB (x) (x) +#define PB (x) (HB(2) + 1 + (x)) + +static void +tda998x_write_if (struct drm_encoder *encoder,uint8_t bit,uint16_t addr, +uint8_t *buf,size_t size) +{ + buf[PB (0 )] =tda998x_cksum (buf, size); + +reg_clear (encoder,REG_DIP_IF_FLAGS , bit); +reg_write_range (encoder, addr, buf, size); +reg_set (encoder,REG_DIP_IF_FLAGS , bit); +} + +static void +tda998x_write_aif (struct drm_encoder *encoder,struct tda998x_encoder_params *p) +{ +uint8_t buf[PB (5 ) +1 ]; + + buf[HB (0 )] =0x84 ; + buf[HB (1 )] =0x01 ; + buf[HB (2 )] =10 ; + buf[PB (0 )] =0 ; + buf[PB (1 )] = p->audio_frame[1 ] &0x07 ;/* CC */ + buf[PB (2 )] = p->audio_frame[2 ] &0x1c ;/* SF */ + buf[PB (4 )] = p->audio_frame[4 ]; + buf[PB (5 )] = p->audio_frame[5 ] &0xf8 ;/* DM_INH + LSV */ + +tda998x_write_if (encoder,DIP_IF_FLAGS_IF4 ,REG_IF4_HB0 , buf, +sizeof (buf)); +} + +static void +tda998x_write_avi (struct drm_encoder *encoder,struct drm_display_mode *mode) +{ +uint8_t buf[PB (13 ) +1 ];
drivers/gpu/drm/i2c/tda998x_drv.c tda998x_reset(struct drm_encoder *encoder) · line 535
Quoted 10 lines
drivers/gpu/drm/i2c/tda998x_drv.c +10
-0+ +memset (buf,0 ,sizeof (buf)); + buf[HB (0 )] =0x82 ; + buf[HB (1 )] =0x02 ; + buf[HB (2 )] =13 ; + buf[PB (4 )] =drm_match_cea_mode (mode); + +tda998x_write_if (encoder,DIP_IF_FLAGS_IF2 ,REG_IF2_HB0 , buf, +sizeof (buf)); +}
fwiw, I expect you could use the hdmi infoframe helpers for some of this (drivers/video/hdmi.c).. it is a relatively recent addition, in case you hadn't seen them already
BR,
-R
Quoted 259 lines
drivers/gpu/drm/i2c/tda998x_drv.c +187
-7+static void tda998x_audio_mute (struct drm_encoder *encoder,bool on) +{ +if (on) { +reg_set (encoder,REG_SOFTRESET ,SOFTRESET_AUDIO ); +reg_clear (encoder,REG_SOFTRESET ,SOFTRESET_AUDIO ); +reg_set (encoder,REG_AIP_CNTRL_0 ,AIP_CNTRL_0_RST_FIFO ); + }else { +reg_clear (encoder,REG_AIP_CNTRL_0 ,AIP_CNTRL_0_RST_FIFO ); + } +} + +static void +tda998x_configure_audio (struct drm_encoder *encoder,struct tda998x_encoder_params *p) +{ +uint8_t buf[6 ], clksel_aip, clksel_fs, ca_i2s, cts_n; +uint32_t n; + +/* SetAudioPortConfig */ +reg_write (encoder,REG_ENA_AP , p->audio_cfg); +/* SetAudioClockPortConfig */ +reg_write (encoder,REG_ENA_ACLK , p->audio_clk_cfg); + +/* +* layout = channelAllocation ? 1 : 0; +* AudioInSetConfig(format, i2sFormat, channelAllocation, +* HDMITX_CHAN_NO_CHANGE, HDMITX_CLKPOLDSD_NO_CHANGE, +* HDMITX_SWAPDSD_NO_CHANGE, layout, HDMITX_LATENCY_CURRENT, +* dstRate) +*/ +switch (p->audio_format) { +case AFMT_SPDIF : +reg_write (encoder,REG_MUX_AP ,0x40 ); + clksel_aip =AIP_CLKSEL_AIP (0 ); +/* FS64SPDIF */ + clksel_fs =AIP_CLKSEL_FS (2 ); + cts_n =CTS_N_M (3 ) |CTS_N_K (3 ); + ca_i2s =0 ; +break ; + +case AFMT_I2S : +reg_write (encoder,REG_MUX_AP ,0x64 ); + clksel_aip =AIP_CLKSEL_AIP (1 ); +/* ACLK */ + clksel_fs =AIP_CLKSEL_FS (0 ); + cts_n =CTS_N_M (3 ) |CTS_N_K (3 ); + ca_i2s =CA_I2S_CA_I2S (0 /* channel allocation */ ); +break ; + } + +reg_write (encoder,REG_AIP_CLKSEL , clksel_aip); +// reg_write(encoder, REG_CA_I2S, ca_i2s); +// reg_write(encoder, REG_I2S_FORMAT, I2S_FORMAT(0 /* i2s format */)); +reg_clear (encoder,REG_AIP_CNTRL_0 ,AIP_CNTRL_0_LAYOUT ); +/* latency? */ + +/* get video format */ + +/* +* ctsRef = HDMITX_CTSREF_FS64SPDIF, uCtsX = HDMITX_CTSX_64 +* AudioInSetCts(ctsRef, rate, VidFmt, vOutFreq, +* HDMITX_CTS_AUTO, uCtsX, HDMITX_CTSK_USE_CTSX, +* HDMITX_CTSMTS_USE_CTSX, dstRate) +*/ +/* Auto CTS */ +reg_clear (encoder,REG_AIP_CNTRL_0 ,AIP_CNTRL_0_ACR_MAN ); +reg_write (encoder,REG_CTS_N , cts_n); +reg_write (encoder,REG_AUDIO_DIV ,3 ); + +/* +* This is the approximate value of N, which happens to be +* the recommended values for non-coherent clocks. +*/ + n =128 * p->audio_sample_rate /1000 ; + +/* Write the CTS and N values */ + buf[0 ] =0x44 ; + buf[1 ] =0x42 ; + buf[2 ] =0x01 ; + buf[3 ] = n; + buf[4 ] = n >>8 ; + buf[5 ] = n >>16 ; +reg_write_range (encoder,REG_ACR_CTS_0 , buf,6 ); + +/* Set CTS clock reference */ +reg_write (encoder,REG_AIP_CLKSEL , clksel_aip | clksel_fs); + +/* Reset CTS generator */ +reg_set (encoder,REG_AIP_CNTRL_0 ,AIP_CNTRL_0_RST_CTS ); +reg_clear (encoder,REG_AIP_CNTRL_0 ,AIP_CNTRL_0_RST_CTS ); + +/* Write the channel status */ + buf[0 ] =0x04 ; + buf[1 ] =0x00 ; + buf[2 ] =0x00 ; + buf[3 ] =0xf1 ; +reg_write_range (encoder,REG_CH_STAT_B (0 ), buf,4 ); + +tda998x_audio_mute (encoder, true); +mdelay (20 ); +tda998x_audio_mute (encoder, false); + +/* Write the audio information packet */ +tda998x_write_aif (encoder, p); +} +/* DRM encoder functions */ static void tda998x_encoder_set_config (struct drm_encoder *encoder,void *params) { +struct tda998x_priv *priv =to_tda998x_priv (encoder); +struct tda998x_encoder_params *p = params; + + priv->vip_cntrl_0 =VIP_CNTRL_0_SWAP_A (p->swap_a) | + (p->mirr_a ?VIP_CNTRL_0_MIRR_A :0 ) | +VIP_CNTRL_0_SWAP_B (p->swap_b) | + (p->mirr_b ?VIP_CNTRL_0_MIRR_B :0 ); + priv->vip_cntrl_1 =VIP_CNTRL_1_SWAP_C (p->swap_c) | + (p->mirr_c ?VIP_CNTRL_1_MIRR_C :0 ) | +VIP_CNTRL_1_SWAP_D (p->swap_d) | + (p->mirr_d ?VIP_CNTRL_1_MIRR_D :0 ); + priv->vip_cntrl_2 =VIP_CNTRL_2_SWAP_E (p->swap_e) | + (p->mirr_e ?VIP_CNTRL_2_MIRR_E :0 ) | +VIP_CNTRL_2_SWAP_F (p->swap_f) | + (p->mirr_f ?VIP_CNTRL_2_MIRR_F :0 ); + + priv->params = *p; + +if (p->audio_cfg) +tda998x_configure_audio (encoder, p); } static void@@ -445,7 +683,8 @@ tda998x_encoder_dpms(struct drm_encoder *encoder, int mode)/* Write the default value MUX register */ reg_write (encoder,REG_MUX_VP_VIP_OUT ,0x24 );/* enable audio and video ports */ -reg_write (encoder,REG_ENA_AP ,0xff ); +// reg_write(encoder, REG_ENA_AP, priv->ena_ap); +// reg_write(encoder, REG_ENA_ACLK, priv->ena_aclk); reg_write (encoder,REG_ENA_VP_0 ,0xff );reg_write (encoder,REG_ENA_VP_1 ,0xff );reg_write (encoder,REG_ENA_VP_2 ,0xff );@@ -456,7 +695,7 @@ tda998x_encoder_dpms(struct drm_encoder *encoder, int mode)break ;case DRM_MODE_DPMS_OFF :/* disable audio and video ports */ -reg_write (encoder,REG_ENA_AP ,0x00 ); +// reg_write(encoder, REG_ENA_AP, 0x00); reg_write (encoder,REG_ENA_VP_0 ,0x00 );reg_write (encoder,REG_ENA_VP_1 ,0x00 );reg_write (encoder,REG_ENA_VP_2 ,0x00 );@@ -607,17 +846,31 @@ tda998x_encoder_mode_set(struct drm_encoder *encoder,reg_write16 (encoder,REG_REFPIX_MSB , ref_pix);reg_write16 (encoder,REG_REFLINE_MSB , ref_line); - reg =TBG_CNTRL_1_VHX_EXT_DE | -TBG_CNTRL_1_VHX_EXT_HS | -TBG_CNTRL_1_VHX_EXT_VS | -TBG_CNTRL_1_DWIN_DIS |/* HDCP off */ + reg =TBG_CNTRL_1_DWIN_DIS |/* HDCP off */ TBG_CNTRL_1_VH_TGL_2 ; +/* +* It is questionable whether this is correct - the nxp driver +* does not set VH_TGL_2 and the below for all display modes. +*/ if (mode->flags & (DRM_MODE_FLAG_NVSYNC |DRM_MODE_FLAG_NHSYNC )) reg |=TBG_CNTRL_1_VH_TGL_0 ;reg_set (encoder,REG_TBG_CNTRL_1 , reg);/* must be last register set: */ reg_clear (encoder,REG_TBG_CNTRL_0 ,TBG_CNTRL_0_SYNC_ONCE ); + +/* Only setup the info frames if the sink is HDMI */ +if (priv->is_hdmi_sink) { +/* We need to turn HDMI HDCP stuff on to get audio through */ +reg_clear (encoder,REG_TBG_CNTRL_1 ,TBG_CNTRL_1_DWIN_DIS ); +reg_write (encoder,REG_ENC_CNTRL ,ENC_CNTRL_CTL_CODE (1 )); +reg_set (encoder,REG_TX33 ,TX33_HDMI ); + +tda998x_write_avi (encoder, adjusted_mode); + +if (priv->params.audio_cfg) +tda998x_configure_audio (encoder, &priv->params); + } } static enum drm_connector_status@@ -743,12 +996,14 @@ static int tda998x_encoder_get_modes(struct drm_encoder *encoder, struct drm_connector *connector) { + struct tda998x_priv *priv = to_tda998x_priv(encoder);struct edid *edid = (struct edid *)do_get_edid (encoder);int n =0 ;if (edid) {drm_mode_connector_update_edid_property (connector, edid); n =drm_add_edid_modes (connector, edid); + priv->is_hdmi_sink =drm_detect_hdmi_monitor (edid);kfree (edid); }@@ -810,6 +1065,40 @@ tda998x_remove(struct i2c_client *client)return 0 ; } +static ssize_t i2c_read_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t size) +{ +struct drm_encoder *encoder =dev_get_drvdata (dev); +unsigned int page, addr; +unsigned char val; + +sscanf (buf,"%x %x" , &page, &addr); + + val =reg_read (encoder,REG (page, addr)); + +printk ("i2c read %02x @ page:%02x address:%02x\n" , val, page, addr); +return size; +} + +static ssize_t i2c_write_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t size) +{ +struct drm_encoder *encoder =dev_get_drvdata (dev); +unsigned int page, addr, mask, val; +unsigned char rval; + +sscanf (buf,"%x %x %x %x" , &page, &addr, &mask, &val); + + rval =reg_read (encoder,REG (page, addr)); + rval &= ~mask; + rval |= val & mask; +reg_write (encoder,REG (page, addr), rval); + +printk ("i2c write %02x @ page:%02x address:%02x\n" , rval, page, addr); +return size; +} + +static DEVICE_ATTR(i2c_read, S_IWUSR, NULL, i2c_read_store); +static DEVICE_ATTR(i2c_write, S_IWUSR, NULL, i2c_write_store); + static int tda998x_encoder_init(struct i2c_client *client, struct drm_device *dev,@@ -817,6 +1106,11 @@ tda998x_encoder_init(struct i2c_client *client, {struct drm_encoder *encoder = &encoder_slave->base;struct tda998x_priv *priv; +/* debug */ +device_create_file (&client->dev, &dev_attr_i2c_read); +device_create_file (&client->dev, &dev_attr_i2c_write); +dev_set_drvdata (&client->dev, encoder); +/* debug end */ priv =kzalloc (sizeof (*priv),GFP_KERNEL );if (!priv) --1.7.4.4