Re: [PATCH 9/9] drm/verisilicon: Add starfive hdmi driver
yes I tested modetest -M starfive -D 0 -s 116@31:1280x720-59.94 -v modetest -M starfive -D 0 -s 116@31:1920x1080 -v and the second command will repeat the problem as you advise at the beginning I call the "starfive_hdmi_setup" function in the "starfive_hdmi_encoder_enable" instead of "starfive_hdmi_encoder_mode_set" resolve the problem i will add this modify in my next patch Thank you Hoegeun On 2023/6/23 10:38, Hoegeun Kwon wrote: > Hi Keith, > > There is a problem with stopping when changing modes. > > Below test log > > root:~> modetest -Mstarfive -c > Connectors: > id encoder status namesize (mm) modes > encoders > 116 115 connected HDMI-A-1320x180 51 115 > modes: > index name refresh (Hz) hdisp hss hse htot vdisp vss vse vtot > #0 1280x800 59.91 1280 1328 1360 1440 800 803 809 823 71000 flags: phsync, > pvsync; type: preferred, driver > #1 1920x1080 60.00 1920 2008 2052 2200 1080 1084 1089 1125 148500 flags: > phsync, pvsync; type: driver > [...] > > root:~> modetest -Mstarfive -s 116:#0 -v > setting mode 1280x800-59.91Hz on connectors 116, crtc 31 > freq: 60.65Hz > freq: 59.91Hz > freq: 59.91Hz > > root:~> modetest -Mstarfive -s 116:#1 -v > setting mode 1920x1080-60.00Hz on connectors 116, crtc 31 > [ 94.535626] rcu: INFO: rcu_sched detected stalls on CPUs/tasks: > [ 94.560985] rcu: 1-...0: (20 ticks this GP) > idle=c9bc/1/0x4000 softirq=3869/3871 fqs=1120 > [ 94.589532] rcu: (detected by 3, t=5264 jiffies, g=4645, q=63 > ncpus=4) > [ 94.615335] Task dump for CPU 1: > [ 94.637723] task:modeteststate:R running task stack:0 > pid:407 ppid:397flags:0x0008 > [ 94.667299] Call Trace: > [ 94.689297] [] __schedule+0x2a8/0xa52 > [ 94.714221] [] schedule+0x5a/0xdc > [ 94.738626] [] schedule_timeout+0x220/0x2a6 > [ 94.763762] [] wait_for_completion+0xfe/0x126 > [ 94.789073] [] kthread_flush_worker+0x82/0xa0 > > >> -Original Message- >> From: dri-devel On Behalf Of >> Keith Zhao >> Sent: Friday, June 2, 2023 4:41 PM >> To: dri-devel@lists.freedesktop.org; devicet...@vger.kernel.org; linux- >> ker...@vger.kernel.org; linux-ri...@lists.infradead.org; linux- >> me...@vger.kernel.org; linaro-mm-...@lists.linaro.org >> Cc: Krzysztof Kozlowski ; Sumit Semwal >> ; Emil Renner Berthing ; >> Shengyang Chen ; Conor Dooley >> ; Albert Ou ; Thomas >> Zimmermann ; Jagan Teki ; Rob >> Herring ; Chris Morgan ; Paul >> Walmsley ; Keith Zhao >> ; Bjorn Andersson ; >> Changhuang Liang ; Jack Zhu >> ; Palmer Dabbelt ; Shawn >> Guo ; christian.koe...@amd.com >> Subject: [PATCH 9/9] drm/verisilicon: Add starfive hdmi driver >> >> Add HDMI dirver for StarFive SoC JH7110. >> >> Signed-off-by: Keith Zhao >> --- >> drivers/gpu/drm/verisilicon/Kconfig | 11 + >> drivers/gpu/drm/verisilicon/Makefile| 1 + >> drivers/gpu/drm/verisilicon/starfive_hdmi.c | 928 >> drivers/gpu/drm/verisilicon/starfive_hdmi.h | 296 +++ >> drivers/gpu/drm/verisilicon/vs_drv.c| 6 + >> drivers/gpu/drm/verisilicon/vs_drv.h| 4 + >> 6 files changed, 1246 insertions(+) >> create mode 100644 drivers/gpu/drm/verisilicon/starfive_hdmi.c >> create mode 100644 drivers/gpu/drm/verisilicon/starfive_hdmi.h > > [...] > >> diff --git a/drivers/gpu/drm/verisilicon/starfive_hdmi.c >> b/drivers/gpu/drm/verisilicon/starfive_hdmi.c >> new file mode 100644 >> index ..128ecca03309 >> --- /dev/null >> +++ b/drivers/gpu/drm/verisilicon/starfive_hdmi.c >> @@ -0,0 +1,928 @@ > > [...] > >> +static int starfive_hdmi_setup(struct starfive_hdmi *hdmi, >> + struct drm_display_mode *mode) { > > [...] > >> +return 0; >> +} >> + >> +static void starfive_hdmi_encoder_mode_set(struct drm_encoder *encoder, >> + struct drm_display_mode *mode, >> + struct drm_display_mode > *adj_mode) { >> +struct starfive_hdmi *hdmi = encoder_to_hdmi(encoder); >> + >> +starfive_hdmi_setup(hdmi, adj_mode); > > When starfive_hdmi_setup runs here, > when changing the mode, a problem occurs because try to write a value to reg > in a state that is not resumed after suspend. > >> + >> +memcpy(&hdmi->previous_mode, adj_mode, sizeof(hdmi- >> >previous_mode)); } >> + >> +static void starfive_hdmi_encoder_enable(struct drm_encoder *encoder) { >> +struct starfive_hdmi *hdmi = encoder_to_hdmi(encoder); >> + >> +pm_runtime_get_sync(hdmi->dev); > > So if move the call point of starfive_hdmi_setup here, it works normally. > >> +} > > Best regards, > Hoegeun > >
Re: [PATCH 4/9] drm/verisilicon: Add gem driver for JH7110 SoC
On 2023/6/19 21:18, Thomas Zimmermann wrote: > > > Am 02.06.23 um 09:40 schrieb Keith Zhao: >> This patch implements gem related APIs for JH7100 SoC. >> >> Signed-off-by: Keith Zhao >> --- >> drivers/gpu/drm/verisilicon/Makefile | 3 +- >> drivers/gpu/drm/verisilicon/vs_drv.c | 6 + >> drivers/gpu/drm/verisilicon/vs_gem.c | 372 +++ >> drivers/gpu/drm/verisilicon/vs_gem.h | 72 ++ >> 4 files changed, 452 insertions(+), 1 deletion(-) >> create mode 100644 drivers/gpu/drm/verisilicon/vs_gem.c >> create mode 100644 drivers/gpu/drm/verisilicon/vs_gem.h >> >> diff --git a/drivers/gpu/drm/verisilicon/Makefile >> b/drivers/gpu/drm/verisilicon/Makefile >> index 64ce1b26546c..30360e370e47 100644 >> --- a/drivers/gpu/drm/verisilicon/Makefile >> +++ b/drivers/gpu/drm/verisilicon/Makefile >> @@ -1,6 +1,7 @@ >> # SPDX-License-Identifier: GPL-2.0 >> -vs_drm-objs := vs_drv.o >> +vs_drm-objs := vs_drv.o \ >> + vs_gem.o >> obj-$(CONFIG_DRM_VERISILICON) += vs_drm.o >> diff --git a/drivers/gpu/drm/verisilicon/vs_drv.c >> b/drivers/gpu/drm/verisilicon/vs_drv.c >> index 24d333598477..e0a2fc43b55f 100644 >> --- a/drivers/gpu/drm/verisilicon/vs_drv.c >> +++ b/drivers/gpu/drm/verisilicon/vs_drv.c >> @@ -30,6 +30,7 @@ >> #include >> #include "vs_drv.h" >> +#include "vs_gem.h" >> #define DRV_NAME "starfive" >> #define DRV_DESC "Starfive DRM driver" >> @@ -47,6 +48,7 @@ static const struct file_operations fops = { >> .compat_ioctl = drm_compat_ioctl, >> .poll = drm_poll, >> .read = drm_read, >> + .mmap = vs_gem_mmap, >> }; >> static struct drm_driver vs_drm_driver = { >> @@ -54,6 +56,10 @@ static struct drm_driver vs_drm_driver = { >> .lastclose = drm_fb_helper_lastclose, >> .prime_handle_to_fd = drm_gem_prime_handle_to_fd, >> .prime_fd_to_handle = drm_gem_prime_fd_to_handle, >> + .gem_prime_import = vs_gem_prime_import, >> + .gem_prime_import_sg_table = vs_gem_prime_import_sg_table, >> + .gem_prime_mmap = vs_gem_prime_mmap, >> + .dumb_create = vs_gem_dumb_create, >> .fops = &fops, >> .name = DRV_NAME, >> .desc = DRV_DESC, >> diff --git a/drivers/gpu/drm/verisilicon/vs_gem.c >> b/drivers/gpu/drm/verisilicon/vs_gem.c >> new file mode 100644 >> index ..3f963471c1ab >> --- /dev/null >> +++ b/drivers/gpu/drm/verisilicon/vs_gem.c >> @@ -0,0 +1,372 @@ >> +// SPDX-License-Identifier: GPL-2.0 >> +/* >> + * Copyright (C) 2023 VeriSilicon Holdings Co., Ltd. >> + */ >> + >> +#include >> +#include >> +#include >> + >> +#include "vs_drv.h" >> +#include "vs_gem.h" >> + >> +static const struct drm_gem_object_funcs vs_gem_default_funcs; >> + >> +static int vs_gem_alloc_buf(struct vs_gem_object *vs_obj) >> +{ >> + struct drm_device *dev = vs_obj->base.dev; >> + unsigned int nr_pages; >> + struct sg_table sgt; >> + int ret = -ENOMEM; >> + >> + if (vs_obj->dma_addr) { >> + DRM_DEV_DEBUG_KMS(dev->dev, "already allocated.\n"); >> + return 0; >> + } >> + >> + vs_obj->dma_attrs = DMA_ATTR_WRITE_COMBINE | DMA_ATTR_FORCE_CONTIGUOUS >> + | DMA_ATTR_NO_KERNEL_MAPPING; >> + >> + nr_pages = vs_obj->size >> PAGE_SHIFT; >> + >> + vs_obj->pages = kvmalloc_array(nr_pages, sizeof(struct page *), >> + GFP_KERNEL | __GFP_ZERO); >> + if (!vs_obj->pages) { >> + DRM_DEV_ERROR(dev->dev, "failed to allocate pages.\n"); >> + return -ENOMEM; >> + } >> + >> + vs_obj->cookie = dma_alloc_attrs(to_dma_dev(dev), vs_obj->size, >> + &vs_obj->dma_addr, GFP_KERNEL, >> + vs_obj->dma_attrs); >> + >> + if (!vs_obj->cookie) { >> + DRM_DEV_ERROR(dev->dev, "failed to allocate buffer.\n"); >> + goto err_free; >> + } >> + >> + vs_obj->iova = vs_obj->dma_addr; >> + >> + ret = dma_get_sgtable_attrs(to_dma_dev(dev), &sgt, >> + vs_obj->cookie, vs_obj->dma_addr, >> + vs_obj->size, vs_obj->
Re: [PATCH 5/9] drm/verisilicon: Add mode config funcs
On 2023/6/21 19:04, Thomas Zimmermann wrote: > Hi Keith > > Am 02.06.23 um 09:40 schrieb Keith Zhao: >> Add mode setting functions for JH7110 SoC. >> >> Signed-off-by: Keith Zhao >> --- >> drivers/gpu/drm/verisilicon/Makefile | 1 + >> drivers/gpu/drm/verisilicon/vs_drv.c | 3 + > >> drivers/gpu/drm/verisilicon/vs_fb.c | 181 +++ >> drivers/gpu/drm/verisilicon/vs_fb.h | 15 +++ > > I'd call these files vs_modeset.{c,h} to be consistent with the rest of the > drivers. > >> 4 files changed, 200 insertions(+) >> create mode 100644 drivers/gpu/drm/verisilicon/vs_fb.c >> create mode 100644 drivers/gpu/drm/verisilicon/vs_fb.h >> >> diff --git a/drivers/gpu/drm/verisilicon/Makefile >> b/drivers/gpu/drm/verisilicon/Makefile >> index 30360e370e47..38254dc5d98d 100644 >> --- a/drivers/gpu/drm/verisilicon/Makefile >> +++ b/drivers/gpu/drm/verisilicon/Makefile >> @@ -1,6 +1,7 @@ >> # SPDX-License-Identifier: GPL-2.0 >> vs_drm-objs := vs_drv.o \ >> + vs_fb.o \ >> vs_gem.o >> obj-$(CONFIG_DRM_VERISILICON) += vs_drm.o >> diff --git a/drivers/gpu/drm/verisilicon/vs_drv.c >> b/drivers/gpu/drm/verisilicon/vs_drv.c >> index e0a2fc43b55f..d84aacd751bc 100644 >> --- a/drivers/gpu/drm/verisilicon/vs_drv.c >> +++ b/drivers/gpu/drm/verisilicon/vs_drv.c >> @@ -30,6 +30,7 @@ >> #include >> #include "vs_drv.h" >> +#include "vs_fb.h" >> #include "vs_gem.h" >> #define DRV_NAME "starfive" >> @@ -118,6 +119,8 @@ static int vs_drm_bind(struct device *dev) >> if (ret) >> goto err_mode; >> + vs_mode_config_init(drm_dev); >> + >> ret = drm_vblank_init(drm_dev, drm_dev->mode_config.num_crtc); >> if (ret) >> goto err_bind; >> diff --git a/drivers/gpu/drm/verisilicon/vs_fb.c >> b/drivers/gpu/drm/verisilicon/vs_fb.c >> new file mode 100644 >> index ..3e85f7365084 >> --- /dev/null >> +++ b/drivers/gpu/drm/verisilicon/vs_fb.c >> @@ -0,0 +1,181 @@ >> +// SPDX-License-Identifier: GPL-2.0 >> +/* >> + * Copyright (C) 2023 VeriSilicon Holdings Co., Ltd. >> + */ >> + >> +#include >> +#include >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +#include "vs_fb.h" >> +#include "vs_gem.h" >> + >> +#define fourcc_mod_vs_get_type(val) \ >> + (((val) & DRM_FORMAT_MOD_VS_TYPE_MASK) >> 54) >> + >> +static struct drm_framebuffer_funcs vs_fb_funcs = { >> + .create_handle = drm_gem_fb_create_handle, >> + .destroy = drm_gem_fb_destroy, >> + .dirty = drm_atomic_helper_dirtyfb, >> +}; >> + >> +static struct drm_framebuffer * >> +vs_fb_alloc(struct drm_device *dev, const struct drm_mode_fb_cmd2 *mode_cmd, >> + struct vs_gem_object **obj, unsigned int num_planes) >> +{ >> + struct drm_framebuffer *fb; >> + int ret, i; >> + >> + fb = kzalloc(sizeof(*fb), GFP_KERNEL); >> + if (!fb) >> + return ERR_PTR(-ENOMEM); >> + >> + drm_helper_mode_fill_fb_struct(dev, fb, mode_cmd); >> + >> + for (i = 0; i < num_planes; i++) >> + fb->obj[i] = &obj[i]->base; >> + >> + ret = drm_framebuffer_init(dev, fb, &vs_fb_funcs); >> + if (ret) { >> + dev_err(dev->dev, "Failed to initialize framebuffer: %d\n", >> + ret); >> + kfree(fb); >> + return ERR_PTR(ret); >> + } >> + >> + return fb; >> +} >> + >> +static struct drm_framebuffer *vs_fb_create(struct drm_device *dev, >> + struct drm_file *file_priv, >> + const struct drm_mode_fb_cmd2 *mode_cmd) >> +{ >> + struct drm_framebuffer *fb; >> + const struct drm_format_info *info; >> + struct vs_gem_object *objs[MAX_NUM_PLANES]; >> + struct drm_gem_object *obj; >> + unsigned int height, size; >> + unsigned char i, num_planes; >> + int ret = 0; >> + >> + info = drm_get_format_info(dev, mode_cmd); >> + if (!info) >> + return ERR_PTR(-EINVAL); >> + >> + num_planes = info->num_planes; >> + if (num_planes > MAX_NUM_PLANES) >> + return ERR_PTR(-EINVAL); >> + >
Re: [PATCH 6/9] drm/verisilicon: Add drm crtc funcs
On 2023/6/30 19:55, Thomas Zimmermann wrote: > Hi > > Am 02.06.23 um 09:40 schrieb Keith Zhao: >> Add crtc driver which implements crtc related operation functions. >> >> Signed-off-by: Keith Zhao >> --- >> drivers/gpu/drm/verisilicon/Makefile | 1 + >> drivers/gpu/drm/verisilicon/vs_crtc.c | 388 ++ >> drivers/gpu/drm/verisilicon/vs_crtc.h | 74 + >> drivers/gpu/drm/verisilicon/vs_type.h | 72 + >> 4 files changed, 535 insertions(+) >> create mode 100644 drivers/gpu/drm/verisilicon/vs_crtc.c >> create mode 100644 drivers/gpu/drm/verisilicon/vs_crtc.h >> create mode 100644 drivers/gpu/drm/verisilicon/vs_type.h >> >> diff --git a/drivers/gpu/drm/verisilicon/Makefile >> b/drivers/gpu/drm/verisilicon/Makefile >> index 38254dc5d98d..bae5fbab9bbb 100644 >> --- a/drivers/gpu/drm/verisilicon/Makefile >> +++ b/drivers/gpu/drm/verisilicon/Makefile >> @@ -1,6 +1,7 @@ >> # SPDX-License-Identifier: GPL-2.0 >> vs_drm-objs := vs_drv.o \ >> + vs_crtc.o \ >> vs_fb.o \ >> vs_gem.o >> diff --git a/drivers/gpu/drm/verisilicon/vs_crtc.c >> b/drivers/gpu/drm/verisilicon/vs_crtc.c >> new file mode 100644 >> index ..a9e742d7bd1a >> --- /dev/null >> +++ b/drivers/gpu/drm/verisilicon/vs_crtc.c >> @@ -0,0 +1,388 @@ >> +// SPDX-License-Identifier: GPL-2.0 >> +/* >> + * Copyright (C) 2023 VeriSilicon Holdings Co., Ltd. >> + * >> + */ >> + >> +#include >> +#include >> +#include >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +#include "vs_crtc.h" >> + >> +void vs_crtc_destroy(struct drm_crtc *crtc) >> +{ >> + struct vs_crtc *vs_crtc = to_vs_crtc(crtc); >> + >> + drm_crtc_cleanup(crtc); >> + kfree(vs_crtc); >> +} >> + >> +static void vs_crtc_reset(struct drm_crtc *crtc) >> +{ >> + struct vs_crtc_state *state; >> + >> + if (crtc->state) { >> + __drm_atomic_helper_crtc_destroy_state(crtc->state); >> + >> + state = to_vs_crtc_state(crtc->state); >> + kfree(state); >> + crtc->state = NULL; >> + } >> + >> + state = kzalloc(sizeof(*state), GFP_KERNEL); >> + if (!state) >> + return; >> + >> + __drm_atomic_helper_crtc_reset(crtc, &state->base); >> + >> + state->sync_mode = VS_SINGLE_DC; >> + state->output_fmt = MEDIA_BUS_FMT_RBG888_1X24; >> + state->encoder_type = DRM_MODE_ENCODER_NONE; >> +} >> + >> +static struct drm_crtc_state * >> +vs_crtc_atomic_duplicate_state(struct drm_crtc *crtc) >> +{ >> + struct vs_crtc_state *ori_state; >> + struct vs_crtc_state *state; >> + >> + if (WARN_ON(!crtc->state)) >> + return NULL; > > I'd leave this check out. IIRC, crtc->state not supposed to be NULL here. > Rather let it crash. > >> + >> + ori_state = to_vs_crtc_state(crtc->state); >> + state = kzalloc(sizeof(*state), GFP_KERNEL); >> + if (!state) >> + return NULL; >> + >> + __drm_atomic_helper_crtc_duplicate_state(crtc, &state->base); >> + >> + state->sync_mode = ori_state->sync_mode; >> + state->output_fmt = ori_state->output_fmt; >> + state->encoder_type = ori_state->encoder_type; >> + state->bg_color = ori_state->bg_color; >> + state->bpp = ori_state->bpp; >> + state->sync_enable = ori_state->sync_enable; >> + state->dither_enable = ori_state->dither_enable; >> + state->underflow = ori_state->underflow; >> + >> + return &state->base; >> +} >> + >> +static void vs_crtc_atomic_destroy_state(struct drm_crtc *crtc, >> + struct drm_crtc_state *state) >> +{ >> + __drm_atomic_helper_crtc_destroy_state(state); >> + kfree(to_vs_crtc_state(state)); >> +} >> + >> +static int vs_crtc_atomic_set_property(struct drm_crtc *crtc, >> + struct drm_crtc_state *state, >> + struct drm_property *property, >> + uint64_t val) >> +{ >> + struct vs_crtc *vs_crtc = to_vs_crtc(crtc); >> + struct vs_crtc_state *vs_crtc_state = to_vs_crtc_state(state); >> + >> + if (property == vs_crtc->sync_mode) >> +
Re: [PATCH 3/9] drm/verisilicon: Add basic drm driver
On 2023/6/7 16:53, Lucas Stach wrote: > Hi Keith, > > Am Freitag, dem 02.06.2023 um 15:40 +0800 schrieb Keith Zhao: >> Add a basic platform driver of the DRM driver for JH7110 SoC. >> >> Signed-off-by: Keith Zhao >> --- >> MAINTAINERS | 2 + >> drivers/gpu/drm/Kconfig | 2 + >> drivers/gpu/drm/Makefile | 1 + >> drivers/gpu/drm/verisilicon/Kconfig | 13 ++ >> drivers/gpu/drm/verisilicon/Makefile | 6 + >> drivers/gpu/drm/verisilicon/vs_drv.c | 284 +++ >> drivers/gpu/drm/verisilicon/vs_drv.h | 48 + >> include/uapi/drm/drm_fourcc.h| 83 >> include/uapi/drm/vs_drm.h| 50 + >> 9 files changed, 489 insertions(+) >> create mode 100644 drivers/gpu/drm/verisilicon/Kconfig >> create mode 100644 drivers/gpu/drm/verisilicon/Makefile >> create mode 100644 drivers/gpu/drm/verisilicon/vs_drv.c >> create mode 100644 drivers/gpu/drm/verisilicon/vs_drv.h >> create mode 100644 include/uapi/drm/vs_drm.h >> >> >> [...] >> +#endif /* __VS_DRV_H__ */ >> diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h >> index de703c6be969..af4fb50f9207 100644 >> --- a/include/uapi/drm/drm_fourcc.h >> +++ b/include/uapi/drm/drm_fourcc.h >> @@ -419,6 +419,7 @@ extern "C" { >> #define DRM_FORMAT_MOD_VENDOR_ARM 0x08 >> #define DRM_FORMAT_MOD_VENDOR_ALLWINNER 0x09 >> #define DRM_FORMAT_MOD_VENDOR_AMLOGIC 0x0a >> +#define DRM_FORMAT_MOD_VENDOR_VS 0x0b >> >> /* add more to the end as needed */ >> >> @@ -1519,6 +1520,88 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 >> modifier) >> #define AMD_FMT_MOD_CLEAR(field) \ >> (~((__u64)AMD_FMT_MOD_##field##_MASK << AMD_FMT_MOD_##field##_SHIFT)) >> >> +#define DRM_FORMAT_MOD_VS_TYPE_NORMAL0x00 >> +#define DRM_FORMAT_MOD_VS_TYPE_COMPRESSED0x01 >> +#define DRM_FORMAT_MOD_VS_TYPE_CUSTOM_10BIT 0x02 >> +#define DRM_FORMAT_MOD_VS_TYPE_MASK ((__u64)0x3 << 54) >> + >> +#define fourcc_mod_vs_code(type, val) \ >> +fourcc_mod_code(VS, __u64)type) << 54) | (val))) >> + >> +#define DRM_FORMAT_MOD_VS_DEC_TILE_MODE_MASK0x3F >> +#define DRM_FORMAT_MOD_VS_DEC_TILE_8X8_XMAJOR 0x00 >> +#define DRM_FORMAT_MOD_VS_DEC_TILE_8X8_YMAJOR 0x01 >> +#define DRM_FORMAT_MOD_VS_DEC_TILE_16X4 0x02 >> +#define DRM_FORMAT_MOD_VS_DEC_TILE_8X4 0x03 >> +#define DRM_FORMAT_MOD_VS_DEC_TILE_4X8 0x04 >> +#define DRM_FORMAT_MOD_VS_DEC_RASTER_16X4 0x06 >> +#define DRM_FORMAT_MOD_VS_DEC_TILE_64X4 0x07 >> +#define DRM_FORMAT_MOD_VS_DEC_TILE_32X4 0x08 >> +#define DRM_FORMAT_MOD_VS_DEC_RASTER_256X1 0x09 >> +#define DRM_FORMAT_MOD_VS_DEC_RASTER_128X1 0x0A >> +#define DRM_FORMAT_MOD_VS_DEC_RASTER_64X4 0x0B >> +#define DRM_FORMAT_MOD_VS_DEC_RASTER_256X2 0x0C >> +#define DRM_FORMAT_MOD_VS_DEC_RASTER_128X2 0x0D >> +#define DRM_FORMAT_MOD_VS_DEC_RASTER_128X4 0x0E >> +#define DRM_FORMAT_MOD_VS_DEC_RASTER_64X1 0x0F >> +#define DRM_FORMAT_MOD_VS_DEC_TILE_16X8 0x10 >> +#define DRM_FORMAT_MOD_VS_DEC_TILE_8X16 0x11 >> +#define DRM_FORMAT_MOD_VS_DEC_RASTER_512X1 0x12 >> +#define DRM_FORMAT_MOD_VS_DEC_RASTER_32X4 0x13 >> +#define DRM_FORMAT_MOD_VS_DEC_RASTER_64X2 0x14 >> +#define DRM_FORMAT_MOD_VS_DEC_RASTER_32X2 0x15 >> +#define DRM_FORMAT_MOD_VS_DEC_RASTER_32X1 0x16 >> +#define DRM_FORMAT_MOD_VS_DEC_RASTER_16X1 0x17 >> +#define DRM_FORMAT_MOD_VS_DEC_TILE_128X40x18 >> +#define DRM_FORMAT_MOD_VS_DEC_TILE_256X40x19 >> +#define DRM_FORMAT_MOD_VS_DEC_TILE_512X40x1A >> +#define DRM_FORMAT_MOD_VS_DEC_TILE_16X160x1B >> +#define DRM_FORMAT_MOD_VS_DEC_TILE_32X160x1C >> +#define DRM_FORMAT_MOD_VS_DEC_TILE_64X160x1D >> +#define DRM_FORMAT_MOD_VS_DEC_TILE_128X80x1E >> +#define DRM_FORMAT_MOD_VS_DEC_TILE_8X4_S0x1F >> +#define DRM_FORMAT_MOD_VS_DEC_TILE_16X4_S 0x20 >> +#define DRM_FORMAT_MOD_VS_DEC_TILE_32X4_S 0x21 >> +#define DRM_FORMAT_MOD_VS_DEC_TILE_16X4_LSB 0x22 >> +#define DRM_FORMAT_MOD_VS_DEC_TILE_32X4_LSB 0x23 >> +#define DRM_FORMAT_MOD_VS_DEC_TILE_32X8 0x24 >> + >> +#define DRM_FORMAT_MOD_VS_DEC_ALIGN_32 (0x01 << 6) >> +#define DRM_FORMAT_MOD_VS_DEC_ALIGN_64 (0x01 << 7) >> + >> +#define fourcc_mod_vs_dec_code(tile, align) \ >> +fourcc_mod_vs_code(DRM_FORMAT_MOD_VS_TYPE_COMPRESSED, \ >> +((tile) | (align))) >> + >
Re: [PATCH 3/9] drm/verisilicon: Add basic drm driver
On 2023/7/25 11:12, Keith Zhao wrote: > > > On 2023/6/7 16:53, Lucas Stach wrote: >> Hi Keith, >> >> Am Freitag, dem 02.06.2023 um 15:40 +0800 schrieb Keith Zhao: >>> Add a basic platform driver of the DRM driver for JH7110 SoC. >>> >>> Signed-off-by: Keith Zhao >>> --- >>> MAINTAINERS | 2 + >>> drivers/gpu/drm/Kconfig | 2 + >>> drivers/gpu/drm/Makefile | 1 + >>> drivers/gpu/drm/verisilicon/Kconfig | 13 ++ >>> drivers/gpu/drm/verisilicon/Makefile | 6 + >>> drivers/gpu/drm/verisilicon/vs_drv.c | 284 +++ >>> drivers/gpu/drm/verisilicon/vs_drv.h | 48 + >>> include/uapi/drm/drm_fourcc.h| 83 >>> include/uapi/drm/vs_drm.h| 50 + >>> 9 files changed, 489 insertions(+) >>> create mode 100644 drivers/gpu/drm/verisilicon/Kconfig >>> create mode 100644 drivers/gpu/drm/verisilicon/Makefile >>> create mode 100644 drivers/gpu/drm/verisilicon/vs_drv.c >>> create mode 100644 drivers/gpu/drm/verisilicon/vs_drv.h >>> create mode 100644 include/uapi/drm/vs_drm.h >>> >>> >>> [...] >>> +#endif /* __VS_DRV_H__ */ >>> diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h >>> index de703c6be969..af4fb50f9207 100644 >>> --- a/include/uapi/drm/drm_fourcc.h >>> +++ b/include/uapi/drm/drm_fourcc.h >>> @@ -419,6 +419,7 @@ extern "C" { >>> #define DRM_FORMAT_MOD_VENDOR_ARM 0x08 >>> #define DRM_FORMAT_MOD_VENDOR_ALLWINNER 0x09 >>> #define DRM_FORMAT_MOD_VENDOR_AMLOGIC 0x0a >>> +#define DRM_FORMAT_MOD_VENDOR_VS 0x0b >>> >>> /* add more to the end as needed */ >>> >>> @@ -1519,6 +1520,88 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 >>> modifier) >>> #define AMD_FMT_MOD_CLEAR(field) \ >>> (~((__u64)AMD_FMT_MOD_##field##_MASK << AMD_FMT_MOD_##field##_SHIFT)) >>> >>> +#define DRM_FORMAT_MOD_VS_TYPE_NORMAL0x00 >>> +#define DRM_FORMAT_MOD_VS_TYPE_COMPRESSED0x01 >>> +#define DRM_FORMAT_MOD_VS_TYPE_CUSTOM_10BIT 0x02 >>> +#define DRM_FORMAT_MOD_VS_TYPE_MASK ((__u64)0x3 << 54) >>> + >>> +#define fourcc_mod_vs_code(type, val) \ >>> + fourcc_mod_code(VS, __u64)type) << 54) | (val))) >>> + >>> +#define DRM_FORMAT_MOD_VS_DEC_TILE_MODE_MASK0x3F >>> +#define DRM_FORMAT_MOD_VS_DEC_TILE_8X8_XMAJOR 0x00 >>> +#define DRM_FORMAT_MOD_VS_DEC_TILE_8X8_YMAJOR 0x01 >>> +#define DRM_FORMAT_MOD_VS_DEC_TILE_16X4 0x02 >>> +#define DRM_FORMAT_MOD_VS_DEC_TILE_8X4 0x03 >>> +#define DRM_FORMAT_MOD_VS_DEC_TILE_4X8 0x04 >>> +#define DRM_FORMAT_MOD_VS_DEC_RASTER_16X4 0x06 >>> +#define DRM_FORMAT_MOD_VS_DEC_TILE_64X4 0x07 >>> +#define DRM_FORMAT_MOD_VS_DEC_TILE_32X4 0x08 >>> +#define DRM_FORMAT_MOD_VS_DEC_RASTER_256X1 0x09 >>> +#define DRM_FORMAT_MOD_VS_DEC_RASTER_128X1 0x0A >>> +#define DRM_FORMAT_MOD_VS_DEC_RASTER_64X4 0x0B >>> +#define DRM_FORMAT_MOD_VS_DEC_RASTER_256X2 0x0C >>> +#define DRM_FORMAT_MOD_VS_DEC_RASTER_128X2 0x0D >>> +#define DRM_FORMAT_MOD_VS_DEC_RASTER_128X4 0x0E >>> +#define DRM_FORMAT_MOD_VS_DEC_RASTER_64X1 0x0F >>> +#define DRM_FORMAT_MOD_VS_DEC_TILE_16X8 0x10 >>> +#define DRM_FORMAT_MOD_VS_DEC_TILE_8X16 0x11 >>> +#define DRM_FORMAT_MOD_VS_DEC_RASTER_512X1 0x12 >>> +#define DRM_FORMAT_MOD_VS_DEC_RASTER_32X4 0x13 >>> +#define DRM_FORMAT_MOD_VS_DEC_RASTER_64X2 0x14 >>> +#define DRM_FORMAT_MOD_VS_DEC_RASTER_32X2 0x15 >>> +#define DRM_FORMAT_MOD_VS_DEC_RASTER_32X1 0x16 >>> +#define DRM_FORMAT_MOD_VS_DEC_RASTER_16X1 0x17 >>> +#define DRM_FORMAT_MOD_VS_DEC_TILE_128X40x18 >>> +#define DRM_FORMAT_MOD_VS_DEC_TILE_256X40x19 >>> +#define DRM_FORMAT_MOD_VS_DEC_TILE_512X40x1A >>> +#define DRM_FORMAT_MOD_VS_DEC_TILE_16X160x1B >>> +#define DRM_FORMAT_MOD_VS_DEC_TILE_32X160x1C >>> +#define DRM_FORMAT_MOD_VS_DEC_TILE_64X160x1D >>> +#define DRM_FORMAT_MOD_VS_DEC_TILE_128X80x1E >>> +#define DRM_FORMAT_MOD_VS_DEC_TILE_8X4_S0x1F >>> +#define DRM_FORMAT_MOD_VS_DEC_TILE_16X4_S 0x20 >>> +#define DRM_FORMAT_MOD_VS_DEC_TILE_32X4_S 0x21 >>> +#define DRM_FORMAT_MOD_VS_DEC_TILE_16X4_LSB 0x22 >>> +#define DRM_FORMAT_MOD_VS_DEC_TILE_32X4_LSB 0x23 >>> +#define DRM_
[PATCH v1 v1 5/7] drm/vs: Register DRM device
Implement drm device registration interface Signed-off-by: Keith Zhao --- drivers/gpu/drm/Kconfig | 2 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/verisilicon/Kconfig | 25 ++ drivers/gpu/drm/verisilicon/Makefile | 13 + drivers/gpu/drm/verisilicon/vs_drv.c | 273 + drivers/gpu/drm/verisilicon/vs_drv.h | 54 drivers/gpu/drm/verisilicon/vs_gem.c | 298 +++ drivers/gpu/drm/verisilicon/vs_gem.h | 50 drivers/gpu/drm/verisilicon/vs_modeset.c | 92 +++ drivers/gpu/drm/verisilicon/vs_modeset.h | 13 + include/uapi/drm/vs_drm.h| 50 11 files changed, 871 insertions(+) create mode 100644 drivers/gpu/drm/verisilicon/Kconfig create mode 100644 drivers/gpu/drm/verisilicon/Makefile create mode 100644 drivers/gpu/drm/verisilicon/vs_drv.c create mode 100644 drivers/gpu/drm/verisilicon/vs_drv.h create mode 100644 drivers/gpu/drm/verisilicon/vs_gem.c create mode 100644 drivers/gpu/drm/verisilicon/vs_gem.h create mode 100644 drivers/gpu/drm/verisilicon/vs_modeset.c create mode 100644 drivers/gpu/drm/verisilicon/vs_modeset.h create mode 100644 include/uapi/drm/vs_drm.h diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index afb3b2f5f..9ede80ef9 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -363,6 +363,8 @@ source "drivers/gpu/drm/solomon/Kconfig" source "drivers/gpu/drm/sprd/Kconfig" +source "drivers/gpu/drm/verisilicon/Kconfig" + config DRM_HYPERV tristate "DRM Support for Hyper-V synthetic video device" depends on DRM && PCI && MMU && HYPERV diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index 7a09a89b4..6db3bc397 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -194,3 +194,4 @@ obj-y += gud/ obj-$(CONFIG_DRM_HYPERV) += hyperv/ obj-y += solomon/ obj-$(CONFIG_DRM_SPRD) += sprd/ +obj-$(CONFIG_DRM_VERISILICON) += verisilicon/ diff --git a/drivers/gpu/drm/verisilicon/Kconfig b/drivers/gpu/drm/verisilicon/Kconfig new file mode 100644 index 0..fcc39dded --- /dev/null +++ b/drivers/gpu/drm/verisilicon/Kconfig @@ -0,0 +1,25 @@ +# SPDX-License-Identifier: GPL-2.0 +config DRM_VERISILICON + tristate "DRM Support for VeriSilicon" + depends on DRM + select DRM_KMS_HELPER + select DRM_GEM_DMA_HELPER + select CMA + select DMA_CMA + help + Choose this option if you have a VeriSilicon soc chipset. + This driver provides VeriSilicon kernel mode + setting and buffer management. It does not + provide 2D or 3D acceleration. + +if DRM_VERISILICON + +config STARFIVE_HDMI + bool "Starfive specific extensions HDMI" + help + This selects support for StarFive SoC specific extensions + for the Innosilicon HDMI driver. If you want to enable + HDMI on JH7110 based SoC, you should select this option. + + To compile this driver as a module, choose M here. +endif diff --git a/drivers/gpu/drm/verisilicon/Makefile b/drivers/gpu/drm/verisilicon/Makefile new file mode 100644 index 0..26cc7e21b --- /dev/null +++ b/drivers/gpu/drm/verisilicon/Makefile @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-2.0 + +vs_drm-objs := vs_dc_hw.o \ + vs_dc.o \ + vs_crtc.o \ + vs_drv.o \ + vs_modeset.o \ + vs_gem.o \ + vs_plane.o + +vs_drm-$(CONFIG_STARFIVE_HDMI) += starfive_hdmi.o +obj-$(CONFIG_DRM_VERISILICON) += vs_drm.o + diff --git a/drivers/gpu/drm/verisilicon/vs_drv.c b/drivers/gpu/drm/verisilicon/vs_drv.c new file mode 100644 index 0..69591e640 --- /dev/null +++ b/drivers/gpu/drm/verisilicon/vs_drv.c @@ -0,0 +1,273 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2023 VeriSilicon Holdings Co., Ltd. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "vs_drv.h" +#include "vs_modeset.h" +#include "vs_gem.h" + +#define DRV_NAME "starfive" +#define DRV_DESC "Starfive DRM driver" +#define DRV_DATE "202305161" +#define DRV_MAJOR 1 +#define DRV_MINOR 0 + +static struct platform_driver vs_drm_platform_driver; + +static const struct file_operations fops = { + .owner = THIS_MODULE, + .open = drm_open, + .release= drm_release, + .unlocked_ioctl = drm_ioctl, + .compat_ioctl = drm_compat_ioctl, + .poll = drm
[PATCH v1 v1 2/7] dt-bindings: display: Add yamls for JH7110 display system
StarFive SoCs JH7110 display system: lcd-controller bases verisilicon dc8200 IP, and hdmi bases Innosilicon IP. Add bindings for them. Signed-off-by: Keith Zhao --- .../starfive/starfive,display-subsystem.yaml | 41 +++ .../starfive/starfive,jh7110-dc8200.yaml | 107 ++ .../starfive/starfive,jh7110-inno-hdmi.yaml | 92 +++ 3 files changed, 240 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/starfive/starfive,display-subsystem.yaml create mode 100644 Documentation/devicetree/bindings/display/starfive/starfive,jh7110-dc8200.yaml create mode 100644 Documentation/devicetree/bindings/display/starfive/starfive,jh7110-inno-hdmi.yaml diff --git a/Documentation/devicetree/bindings/display/starfive/starfive,display-subsystem.yaml b/Documentation/devicetree/bindings/display/starfive/starfive,display-subsystem.yaml new file mode 100644 index 0..86018a8e6 --- /dev/null +++ b/Documentation/devicetree/bindings/display/starfive/starfive,display-subsystem.yaml @@ -0,0 +1,41 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/starfive/starfive,display-subsystem.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Starfive DRM master device + +maintainers: + - Keith Zhao + - ShengYang Chen + +description: + The Starfive DRM master device is a virtual device needed to list all + display controller or other display interface nodes that comprise the + graphics subsystem. + +properties: + compatible: +const: starfive,display-subsystem + + ports: +$ref: /schemas/graph.yaml#/properties/ports +description: | + Should contain a list of phandles pointing to display interface ports + of display controller devices. Display controller definitions as defined + in Documentation/devicetree/bindings/display/starfive/ + starfive,jh7110-dc8200.yaml + +required: + - compatible + - ports + +additionalProperties: false + +examples: + - | +display-subsystem { +compatible = "starfive,display-subsystem"; +ports = <&dc_out>; +}; diff --git a/Documentation/devicetree/bindings/display/starfive/starfive,jh7110-dc8200.yaml b/Documentation/devicetree/bindings/display/starfive/starfive,jh7110-dc8200.yaml new file mode 100644 index 0..bebe2050c --- /dev/null +++ b/Documentation/devicetree/bindings/display/starfive/starfive,jh7110-dc8200.yaml @@ -0,0 +1,107 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/starfive/starfive,jh7110-dc8200.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: StarFive display controller + +description: + The StarFive SoC uses the display controller based on Verisilicon IP + to transfer the image data from a video memory + buffer to an external LCD interface. + +maintainers: + - Keith Zhao + +properties: + compatible: +const: starfive,jh7110-dc8200 + + reg: +maxItems: 3 + + interrupts: +items: + - description: The interrupt will be generated when DC finish one frame + + clocks: +items: + - description: Clock for display system noc bus. + - description: Pixel clock for display channel 0. + - description: Pixel clock for display channel 1. + - description: Clock for axi interface of display controller. + - description: Core clock for display controller. + - description: Clock for ahb interface of display controller. + - description: External HDMI pixel clock. + - description: Parent clock for pixel clock + + clock-names: +items: + - const: vout_noc_disp + - const: vout_pix0 + - const: vout_pix1 + - const: vout_axi + - const: vout_core + - const: vout_vout_ahb + - const: hdmitx0_pixel + - const: vout_dc8200 + + resets: +items: + - description: Reset for axi interface of display controller. + - description: Reset for ahb interface of display controller. + - description: Core reset of display controller. + + reset-names: +items: + - const: vout_axi + - const: vout_ahb + - const: vout_core + + port: +$ref: /schemas/graph.yaml#/properties/port +description: + A port node with endpoint definitions as defined in + Documentation/devicetree/bindings/media/video-interfaces.txt. + +required: + - compatible + - reg + - interrupts + - clocks + - clock-names + - resets + - reset-names + - port + +additionalProperties: false + +examples: + - | +dc8200: lcd-controller@2940 { +compatible = "starfive,jh7110-dc8200"; +reg = <0x2940 0x100>, <0x29400800 0x2000>, <0x295b 0x90>; +interrupts = <95>; +clocks = <&syscrg 60>, + <&voutcrg 7>, + <&voutcrg 8>, +
[PATCH v1 v1 3/7] riscv: dts: starfive: jh7110: add dc controller and hdmi node
Add the dc controller and hdmi node for the Starfive JH7110 SoC. Signed-off-by: Keith Zhao --- .../jh7110-starfive-visionfive-2.dtsi | 87 +++ arch/riscv/boot/dts/starfive/jh7110.dtsi | 43 + 2 files changed, 130 insertions(+) diff --git a/arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-2.dtsi b/arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-2.dtsi index de0f40a8b..32e5cc96c 100644 --- a/arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-2.dtsi +++ b/arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-2.dtsi @@ -31,6 +31,21 @@ memory@4000 { reg = <0x0 0x4000 0x1 0x0>; }; + reserved-memory { + #address-cells = <2>; + #size-cells = <2>; + ranges; + + linux,cma { + compatible = "shared-dma-pool"; + reusable; + size = <0x0 0x2000>; + alignment = <0x0 0x1000>; + alloc-ranges = <0x0 0x8000 0x0 0x2000>; + linux,cma-default; + }; + }; + gpio-restart { compatible = "gpio-restart"; gpios = <&sysgpio 35 GPIO_ACTIVE_HIGH>; @@ -231,6 +246,41 @@ GPOEN_DISABLE, slew-rate = <0>; }; }; + + hdmi_pins: hdmi-0 { + hdmi-scl-pins { + pinmux = ; + input-enable; + bias-pull-up; + }; + + hdmi-sda-pins { + pinmux = ; + input-enable; + bias-pull-up; + }; + + hdmi-cec-pins { + pinmux = ; + input-enable; + bias-pull-up; + }; + + hdmi-hpd-pins { + pinmux = ; + input-enable; + bias-disable; /* external pull-up */ + }; + }; + }; &uart0 { @@ -254,3 +304,40 @@ &U74_3 { &U74_4 { cpu-supply = <&vdd_cpu>; }; + +&voutcrg { + status = "okay"; +}; + +&display { + status = "okay"; +}; + +&hdmi { + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <&hdmi_pins>; + + hdmi_in: port { + #address-cells = <1>; + #size-cells = <0>; + hdmi_in_dc: endpoint@0 { + reg = <0>; + remote-endpoint = <&dc_out_hdmi>; + }; + }; +}; + +&dc8200 { + status = "okay"; + + dc_out: port { + #address-cells = <1>; + #size-cells = <0>; + dc_out_hdmi: endpoint@0 { + reg = <0>; + remote-endpoint = <&hdmi_in_dc>; + }; + + }; +}; diff --git a/arch/riscv/boot/dts/starfive/jh7110.dtsi b/arch/riscv/boot/dts/starfive/jh7110.dtsi index 0005fa163..b8c527d9f 100644 --- a/arch/riscv/boot/dts/starfive/jh7110.dtsi +++ b/arch/riscv/boot/dts/starfive/jh7110.dtsi @@ -282,6 +282,11 @@ tdm_ext: tdm-ext-clock { #clock-cells = <0>; }; + display: display-subsystem { + compatible = "starfive,display-subsystem"; + ports = <&dc_out>; + }; + soc { compatible = "simple-bus"; interrupt-parent = <&plic>; @@ -613,5 +618,43 @@ voutcrg: clock-controller@295c { #reset-cells = <1>; power-domains = <&pwrc JH7110_PD_VOUT>; }; + + dc8200: lcd-controller@2940 { + compatible = "starfive,jh7110-dc8200"; + reg = <0x0 0x2940 0x0 0x100>, + <0x0 0x29400800 0x0 0x2000>, + <0x0 0x295b 0x0 0x90>; + interrupts = <95>; + clocks = <&syscrg JH7110_SYSCLK_NOC_BUS_DISP_AXI>, + <&voutcrg JH7110_VOUTCLK_DC8200_PIX0>, + <&voutcrg JH7110_VOUTCLK_DC8200_PIX1>, + <&voutcrg JH7110_VOUTCLK_DC8200_AXI>, + <&voutcrg JH7110_VOUTCLK_DC8200_CORE>, + <&voutcrg JH7110_VOUTCLK_DC8200_AHB>, + <&hdmitx0_pixelclk>, + <&voutcrg
[PATCH v1 v1 0/7] DRM driver for verisilicon
This patch is a drm driver for Starfive Soc JH7110, I am sending Drm driver part and HDMI driver part. We used GEM framework for buffer management , and for buffer allocation,we use DMA APIs. the Starfive HDMI servers as interface between a LCD Controller and a HDMI bus. A HDMI TX consists of one HDMI transmitter controller and one HDMI transmitter PHY. (Sound support is not include in this patch) This patchset should be applied after the patchset: https://patchwork.kernel.org/project/linux-clk/cover/20230713113902.56519-1-xingyu...@starfivetech.com/ V1: Changes since v1: - Further standardize the yaml file. - Dts naming convention improved. - Fix the problem of compiling and loading ko files. - Use drm new api to automatically manage resources. - Drop struct vs_crtc_funcs&vs_plane_funcs,subdivide the plane's help interface - Reduce the modifiers unused. - Optimize the hdmi driver code Keith Zhao (7): MAINTAINERS: Update starfive maintainers dt-bindings: display: Add yamls for JH7110 display system riscv: dts: starfive: jh7110: add dc controller and hdmi node drm/fourcc: Add drm/vs tiled modifiers drm/vs: Register DRM device drm/vs: Add KMS crtc&plane drm/vs: Add hdmi .../starfive/starfive,display-subsystem.yaml | 41 + .../starfive/starfive,jh7110-dc8200.yaml | 107 + .../starfive/starfive,jh7110-inno-hdmi.yaml | 92 + MAINTAINERS |7 + .../jh7110-starfive-visionfive-2.dtsi | 87 + arch/riscv/boot/dts/starfive/jh7110.dtsi | 43 + drivers/gpu/drm/Kconfig |2 + drivers/gpu/drm/Makefile |1 + drivers/gpu/drm/verisilicon/Kconfig | 25 + drivers/gpu/drm/verisilicon/Makefile | 13 + drivers/gpu/drm/verisilicon/starfive_hdmi.c | 940 drivers/gpu/drm/verisilicon/starfive_hdmi.h | 295 +++ drivers/gpu/drm/verisilicon/vs_crtc.c | 365 +++ drivers/gpu/drm/verisilicon/vs_crtc.h | 54 + drivers/gpu/drm/verisilicon/vs_dc.c | 1036 + drivers/gpu/drm/verisilicon/vs_dc.h | 87 + drivers/gpu/drm/verisilicon/vs_dc_hw.c| 2008 + drivers/gpu/drm/verisilicon/vs_dc_hw.h| 496 drivers/gpu/drm/verisilicon/vs_drv.c | 274 +++ drivers/gpu/drm/verisilicon/vs_drv.h | 54 + drivers/gpu/drm/verisilicon/vs_gem.c | 298 +++ drivers/gpu/drm/verisilicon/vs_gem.h | 50 + drivers/gpu/drm/verisilicon/vs_modeset.c | 92 + drivers/gpu/drm/verisilicon/vs_modeset.h | 13 + drivers/gpu/drm/verisilicon/vs_plane.c| 502 + drivers/gpu/drm/verisilicon/vs_plane.h| 65 + drivers/gpu/drm/verisilicon/vs_type.h | 70 + include/uapi/drm/drm_fourcc.h | 27 + include/uapi/drm/vs_drm.h | 50 + 29 files changed, 7194 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/starfive/starfive,display-subsystem.yaml create mode 100644 Documentation/devicetree/bindings/display/starfive/starfive,jh7110-dc8200.yaml create mode 100644 Documentation/devicetree/bindings/display/starfive/starfive,jh7110-inno-hdmi.yaml create mode 100644 drivers/gpu/drm/verisilicon/Kconfig create mode 100644 drivers/gpu/drm/verisilicon/Makefile create mode 100644 drivers/gpu/drm/verisilicon/starfive_hdmi.c create mode 100644 drivers/gpu/drm/verisilicon/starfive_hdmi.h create mode 100644 drivers/gpu/drm/verisilicon/vs_crtc.c create mode 100644 drivers/gpu/drm/verisilicon/vs_crtc.h create mode 100644 drivers/gpu/drm/verisilicon/vs_dc.c create mode 100644 drivers/gpu/drm/verisilicon/vs_dc.h create mode 100644 drivers/gpu/drm/verisilicon/vs_dc_hw.c create mode 100644 drivers/gpu/drm/verisilicon/vs_dc_hw.h create mode 100644 drivers/gpu/drm/verisilicon/vs_drv.c create mode 100644 drivers/gpu/drm/verisilicon/vs_drv.h create mode 100644 drivers/gpu/drm/verisilicon/vs_gem.c create mode 100644 drivers/gpu/drm/verisilicon/vs_gem.h create mode 100644 drivers/gpu/drm/verisilicon/vs_modeset.c create mode 100644 drivers/gpu/drm/verisilicon/vs_modeset.h create mode 100644 drivers/gpu/drm/verisilicon/vs_plane.c create mode 100644 drivers/gpu/drm/verisilicon/vs_plane.h create mode 100644 drivers/gpu/drm/verisilicon/vs_type.h create mode 100644 include/uapi/drm/vs_drm.h -- 2.34.1
[PATCH v1 v1 4/7] drm/fourcc: Add drm/vs tiled modifiers
These are mainly used internally in vs-drm, I'm not sure if the new modifiers can be used with the existing ones. If there is a problem, I will improve it further. Signed-off-by: Keith Zhao --- include/uapi/drm/drm_fourcc.h | 27 +++ 1 file changed, 27 insertions(+) diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h index 8db7fd3f7..0b884cf50 100644 --- a/include/uapi/drm/drm_fourcc.h +++ b/include/uapi/drm/drm_fourcc.h @@ -419,6 +419,7 @@ extern "C" { #define DRM_FORMAT_MOD_VENDOR_ARM 0x08 #define DRM_FORMAT_MOD_VENDOR_ALLWINNER 0x09 #define DRM_FORMAT_MOD_VENDOR_AMLOGIC 0x0a +#define DRM_FORMAT_MOD_VENDOR_VS 0x0b /* add more to the end as needed */ @@ -1562,6 +1563,32 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier) #define AMD_FMT_MOD_CLEAR(field) \ (~((__u64)AMD_FMT_MOD_##field##_MASK << AMD_FMT_MOD_##field##_SHIFT)) +#define DRM_FORMAT_MOD_VS_TYPE_NORMAL0x00 +#define DRM_FORMAT_MOD_VS_TYPE_COMPRESSED0x01 +#define DRM_FORMAT_MOD_VS_TYPE_CUSTOM_10BIT 0x02 +#define DRM_FORMAT_MOD_VS_TYPE_MASK ((__u64)0x3 << 54) + +#define fourcc_mod_vs_code(type, val) \ + fourcc_mod_code(VS, __u64)type) << 54) | (val))) + +#define DRM_FORMAT_MOD_VS_NORM_MODE_MASK0x1F +#define DRM_FORMAT_MOD_VS_LINEAR0x00 +#define DRM_FORMAT_MOD_VS_SUPER_TILED_XMAJOR0x02 +#define DRM_FORMAT_MOD_VS_SUPER_TILED_YMAJOR0x03 +#define DRM_FORMAT_MOD_VS_TILE_8X8 0x04 +#define DRM_FORMAT_MOD_VS_TILE_8X4 0x07 +#define DRM_FORMAT_MOD_VS_SUPER_TILED_XMAJOR_8X40x0B +#define DRM_FORMAT_MOD_VS_SUPER_TILED_YMAJOR_4X80x0C +#define DRM_FORMAT_MOD_VS_TILE_MODE4X4 0x15 + +#define fourcc_mod_vs_norm_code(tile) \ + fourcc_mod_vs_code(DRM_FORMAT_MOD_VS_TYPE_NORMAL, \ + (tile)) + +#define fourcc_mod_vs_custom_code(tile) \ + fourcc_mod_vs_code(DRM_FORMAT_MOD_VS_TYPE_CUSTOM_10BIT, \ + (tile)) + #if defined(__cplusplus) } #endif -- 2.34.1
dri-devel@lists.freedesktop.org
add 2 crtcs and 8 planes in vs-drm Signed-off-by: Keith Zhao --- drivers/gpu/drm/verisilicon/vs_crtc.c | 365 + drivers/gpu/drm/verisilicon/vs_crtc.h | 54 + drivers/gpu/drm/verisilicon/vs_dc.c| 1036 drivers/gpu/drm/verisilicon/vs_dc.h| 87 + drivers/gpu/drm/verisilicon/vs_dc_hw.c | 2008 drivers/gpu/drm/verisilicon/vs_dc_hw.h | 496 ++ drivers/gpu/drm/verisilicon/vs_drv.c |3 +- drivers/gpu/drm/verisilicon/vs_plane.c | 502 ++ drivers/gpu/drm/verisilicon/vs_plane.h | 65 + drivers/gpu/drm/verisilicon/vs_type.h | 70 + 10 files changed, 4685 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/verisilicon/vs_crtc.c create mode 100644 drivers/gpu/drm/verisilicon/vs_crtc.h create mode 100644 drivers/gpu/drm/verisilicon/vs_dc.c create mode 100644 drivers/gpu/drm/verisilicon/vs_dc.h create mode 100644 drivers/gpu/drm/verisilicon/vs_dc_hw.c create mode 100644 drivers/gpu/drm/verisilicon/vs_dc_hw.h create mode 100644 drivers/gpu/drm/verisilicon/vs_plane.c create mode 100644 drivers/gpu/drm/verisilicon/vs_plane.h create mode 100644 drivers/gpu/drm/verisilicon/vs_type.h diff --git a/drivers/gpu/drm/verisilicon/vs_crtc.c b/drivers/gpu/drm/verisilicon/vs_crtc.c new file mode 100644 index 0..6a5af8d8c --- /dev/null +++ b/drivers/gpu/drm/verisilicon/vs_crtc.c @@ -0,0 +1,365 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2023 VeriSilicon Holdings Co., Ltd. + * + */ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "vs_crtc.h" +#include "vs_dc.h" +#include "vs_drv.h" + +static void vs_crtc_reset(struct drm_crtc *crtc) +{ + struct vs_crtc_state *state; + + if (crtc->state) { + __drm_atomic_helper_crtc_destroy_state(crtc->state); + + state = to_vs_crtc_state(crtc->state); + kfree(state); + crtc->state = NULL; + } + + state = kzalloc(sizeof(*state), GFP_KERNEL); + if (!state) + return; + + __drm_atomic_helper_crtc_reset(crtc, &state->base); + + state->sync_mode = VS_SINGLE_DC; + state->output_fmt = MEDIA_BUS_FMT_RBG888_1X24; + state->encoder_type = DRM_MODE_ENCODER_NONE; +} + +static struct drm_crtc_state * +vs_crtc_atomic_duplicate_state(struct drm_crtc *crtc) +{ + struct vs_crtc_state *ori_state; + struct vs_crtc_state *state; + + if (!crtc->state) + return NULL; + + ori_state = to_vs_crtc_state(crtc->state); + state = kzalloc(sizeof(*state), GFP_KERNEL); + if (!state) + return NULL; + + __drm_atomic_helper_crtc_duplicate_state(crtc, &state->base); + + state->sync_mode = ori_state->sync_mode; + state->output_fmt = ori_state->output_fmt; + state->encoder_type = ori_state->encoder_type; + state->bg_color = ori_state->bg_color; + state->bpp = ori_state->bpp; + state->sync_enable = ori_state->sync_enable; + state->dither_enable = ori_state->dither_enable; + state->underflow = ori_state->underflow; + + return &state->base; +} + +static void vs_crtc_atomic_destroy_state(struct drm_crtc *crtc, +struct drm_crtc_state *state) +{ + __drm_atomic_helper_crtc_destroy_state(state); + kfree(to_vs_crtc_state(state)); +} + +static int vs_crtc_atomic_set_property(struct drm_crtc *crtc, + struct drm_crtc_state *state, + struct drm_property *property, + uint64_t val) +{ + struct vs_crtc *vs_crtc = to_vs_crtc(crtc); + struct vs_crtc_state *vs_crtc_state = to_vs_crtc_state(state); + + if (property == vs_crtc->sync_mode) + vs_crtc_state->sync_mode = val; + else if (property == vs_crtc->mmu_prefetch) + vs_crtc_state->mmu_prefetch = val; + else if (property == vs_crtc->bg_color) + vs_crtc_state->bg_color = val; + else if (property == vs_crtc->panel_sync) + vs_crtc_state->sync_enable = val; + else if (property == vs_crtc->dither) + vs_crtc_state->dither_enable = val; + else + return -EINVAL; + + return 0; +} + +static int vs_crtc_atomic_get_property(struct drm_crtc *crtc, + const struct drm_crtc_state *state, + struct drm_property *property, + uint64_t *val) +{ + struct vs_crtc *vs_crtc = to_vs_crtc(crtc); + const struct vs_crtc_state *vs_crtc_state = + container_of(state, const struct vs_crtc_state, base); + + i
[PATCH v1 v1 1/7] MAINTAINERS: Update starfive maintainers
update starfive maintainers Signed-off-by: Keith Zhao --- MAINTAINERS | 7 +++ 1 file changed, 7 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 3be1bdfe8..daadd1707 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6760,6 +6760,13 @@ S: Supported T: git git://anongit.freedesktop.org/drm/drm-misc F: drivers/gpu/drm/udl/ +DRM DRIVERS FOR STARFIVE +M: Keith Zhao +L: dri-devel@lists.freedesktop.org +S: Maintained +T: git git://anongit.freedesktop.org/drm/drm-misc +F: Documentation/devicetree/bindings/display/starfive/ + DRM DRIVER FOR VIRTUAL KERNEL MODESETTING (VKMS) M: Rodrigo Siqueira M: Melissa Wen -- 2.34.1
[PATCH v1 v1 7/7] drm/vs: Add hdmi
add hdmi driver as encoder and connect Signed-off-by: Keith Zhao --- drivers/gpu/drm/verisilicon/starfive_hdmi.c | 940 drivers/gpu/drm/verisilicon/starfive_hdmi.h | 295 ++ 2 files changed, 1235 insertions(+) create mode 100644 drivers/gpu/drm/verisilicon/starfive_hdmi.c create mode 100644 drivers/gpu/drm/verisilicon/starfive_hdmi.h diff --git a/drivers/gpu/drm/verisilicon/starfive_hdmi.c b/drivers/gpu/drm/verisilicon/starfive_hdmi.c new file mode 100644 index 0..c02f4f749 --- /dev/null +++ b/drivers/gpu/drm/verisilicon/starfive_hdmi.c @@ -0,0 +1,940 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2023 StarFive Technology Co., Ltd. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "starfive_hdmi.h" +#include "vs_drv.h" + +static struct starfive_hdmi *encoder_to_hdmi(struct drm_encoder *encoder) +{ + return container_of(encoder, struct starfive_hdmi, encoder); +} + +static struct starfive_hdmi *connector_to_hdmi(struct drm_connector *connector) +{ + return container_of(connector, struct starfive_hdmi, connector); +} + +struct starfive_hdmi_i2c { + struct i2c_adapter adap; + + u8 ddc_addr; + u8 segment_addr; + /* protects the edid data when use i2c cmd to read edid */ + struct mutex lock; + struct completion cmp; +}; + +static const struct pre_pll_config pre_pll_cfg_table[] = { + { 25175000, 25175000, 1, 100, 2, 3, 3, 12, 3, 3, 4, 0, 0xf5}, + { 2520, 2520, 1, 100, 2, 3, 3, 12, 3, 3, 4, 0, 0}, + { 2700, 2700, 1, 90, 3, 2, 2, 10, 3, 3, 4, 0, 0}, + { 27027000, 27027000, 1, 90, 3, 2, 2, 10, 3, 3, 4, 0, 0x170a3d}, + { 2832, 2832, 1, 28, 2, 1, 1, 3, 0, 3, 4, 0, 0x51eb85}, + { 3024, 3024, 1, 30, 2, 1, 1, 3, 0, 3, 4, 0, 0x3d70a3}, + { 3150, 3150, 1, 31, 2, 1, 1, 3, 0, 3, 4, 0, 0x7f}, + { 3375, 3375, 1, 33, 2, 1, 1, 3, 0, 3, 4, 0, 0xcf}, + { 3600, 3600, 1, 36, 2, 1, 1, 3, 0, 3, 4, 0, 0}, + { 4000, 4000, 1, 80, 2, 2, 2, 12, 2, 2, 2, 0, 0}, + { 4697, 4697, 1, 46, 2, 1, 1, 3, 0, 3, 4, 0, 0xf851eb}, + { 4950, 4950, 1, 49, 2, 1, 1, 3, 0, 3, 4, 0, 0x7f}, + { 4900, 4900, 1, 49, 2, 1, 1, 3, 0, 3, 4, 0, 0}, + { 5000, 5000, 1, 50, 2, 1, 1, 3, 0, 3, 4, 0, 0}, + { 5400, 5400, 1, 54, 2, 1, 1, 3, 0, 3, 4, 0, 0}, + { 54054000, 54054000, 1, 54, 2, 1, 1, 3, 0, 3, 4, 0, 0x0dd2f1}, + { 57284000, 57284000, 1, 57, 2, 1, 1, 3, 0, 3, 4, 0, 0x48b439}, + { 5823, 5823, 1, 58, 2, 1, 1, 3, 0, 3, 4, 0, 0x3ae147}, + { 59341000, 59341000, 1, 59, 2, 1, 1, 3, 0, 3, 4, 0, 0x574bc6}, + { 5940, 5940, 1, 99, 3, 1, 1, 1, 3, 3, 4, 0, 0}, + { 6500, 6500, 1, 130, 2, 2, 2, 12, 0, 2, 2, 0, 0}, + { 6825, 6825, 1, 68, 2, 1, 1, 3, 0, 3, 4, 0, 0x3f}, + { 7100, 7100, 1, 71, 2, 1, 1, 3, 0, 3, 4, 0, 0}, + { 74176000, 74176000, 1, 98, 1, 2, 2, 1, 2, 3, 4, 0, 0xe6ae6b}, + { 7425, 7425, 1, 99, 1, 2, 2, 1, 2, 3, 4, 0, 0}, + { 7500, 7500, 1, 75, 2, 1, 1, 3, 0, 3, 4, 0, 0}, + { 7875, 7875, 1, 78, 2, 1, 1, 3, 0, 3, 4, 0, 0xcf}, + { 7950, 7950, 1, 79, 2, 1, 1, 3, 0, 3, 4, 0, 0x7f}, + { 8350, 8350, 2, 167, 2, 1, 1, 1, 0, 0, 6, 0, 0}, + { 8350, 104375000, 1, 104, 2, 1, 1, 1, 1, 0, 5, 0, 0x60}, + { 84858000, 84858000, 1, 85, 2, 1, 1, 3, 0, 3, 4, 0, 0xdba5e2}, + { 8550, 8550, 1, 85, 2, 1, 1, 3, 0, 3, 4, 0, 0x7f}, + { 8575, 8575, 1, 85, 2, 1, 1, 3, 0, 3, 4, 0, 0xcf}, + { 8580, 8580, 1, 85, 2, 1, 1, 3, 0, 3, 4, 0, 0xcc}, + { 8875, 8875, 1, 88, 2, 1, 1, 3, 0, 3, 4, 0, 0xcf}, + { 8991, 8991, 1, 89, 2, 1, 1, 3, 0, 3, 4, 0, 0xe8f5c1}, + { 9000, 9000, 1, 90, 2, 1, 1, 3, 0, 3, 4, 0, 0}, + {10100, 10100, 1, 101, 2, 1, 1, 3, 0, 3, 4, 0, 0}, + {10225, 10225, 1, 102, 2, 1, 1, 3, 0, 3, 4, 0, 0x3f}, + {10650, 10650, 1, 106, 2, 1, 1, 3, 0, 3, 4, 0, 0x7f}, + {10800, 10800, 1, 90, 3, 0, 0, 5, 0, 2, 2, 0, 0}, + {11900, 11900, 1, 119, 2, 1, 1, 3, 0, 3, 4, 0, 0}, + {131481000, 131481000, 1, 131, 2, 1, 1, 3, 0, 3, 4, 0, 0x7b22d1}, + {13500, 13500, 1, 135, 2, 1, 1, 3, 0, 3, 4, 0, 0}, + {13675, 13675, 1, 136, 2, 1, 1, 3, 0, 3, 4, 0, 0xcf}, + {14718, 14718, 1, 147, 2, 1, 1, 3, 0, 3, 4, 0, 0x2e147a}, + {148352000, 148352000, 1, 98,
[PATCH 6/9] drm/verisilicon: Add drm crtc funcs
Add crtc driver which implements crtc related operation functions. Signed-off-by: Keith Zhao --- drivers/gpu/drm/verisilicon/Makefile | 1 + drivers/gpu/drm/verisilicon/vs_crtc.c | 388 ++ drivers/gpu/drm/verisilicon/vs_crtc.h | 74 + drivers/gpu/drm/verisilicon/vs_type.h | 72 + 4 files changed, 535 insertions(+) create mode 100644 drivers/gpu/drm/verisilicon/vs_crtc.c create mode 100644 drivers/gpu/drm/verisilicon/vs_crtc.h create mode 100644 drivers/gpu/drm/verisilicon/vs_type.h diff --git a/drivers/gpu/drm/verisilicon/Makefile b/drivers/gpu/drm/verisilicon/Makefile index 38254dc5d98d..bae5fbab9bbb 100644 --- a/drivers/gpu/drm/verisilicon/Makefile +++ b/drivers/gpu/drm/verisilicon/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 vs_drm-objs := vs_drv.o \ + vs_crtc.o \ vs_fb.o \ vs_gem.o diff --git a/drivers/gpu/drm/verisilicon/vs_crtc.c b/drivers/gpu/drm/verisilicon/vs_crtc.c new file mode 100644 index ..a9e742d7bd1a --- /dev/null +++ b/drivers/gpu/drm/verisilicon/vs_crtc.c @@ -0,0 +1,388 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2023 VeriSilicon Holdings Co., Ltd. + * + */ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "vs_crtc.h" + +void vs_crtc_destroy(struct drm_crtc *crtc) +{ + struct vs_crtc *vs_crtc = to_vs_crtc(crtc); + + drm_crtc_cleanup(crtc); + kfree(vs_crtc); +} + +static void vs_crtc_reset(struct drm_crtc *crtc) +{ + struct vs_crtc_state *state; + + if (crtc->state) { + __drm_atomic_helper_crtc_destroy_state(crtc->state); + + state = to_vs_crtc_state(crtc->state); + kfree(state); + crtc->state = NULL; + } + + state = kzalloc(sizeof(*state), GFP_KERNEL); + if (!state) + return; + + __drm_atomic_helper_crtc_reset(crtc, &state->base); + + state->sync_mode = VS_SINGLE_DC; + state->output_fmt = MEDIA_BUS_FMT_RBG888_1X24; + state->encoder_type = DRM_MODE_ENCODER_NONE; +} + +static struct drm_crtc_state * +vs_crtc_atomic_duplicate_state(struct drm_crtc *crtc) +{ + struct vs_crtc_state *ori_state; + struct vs_crtc_state *state; + + if (WARN_ON(!crtc->state)) + return NULL; + + ori_state = to_vs_crtc_state(crtc->state); + state = kzalloc(sizeof(*state), GFP_KERNEL); + if (!state) + return NULL; + + __drm_atomic_helper_crtc_duplicate_state(crtc, &state->base); + + state->sync_mode = ori_state->sync_mode; + state->output_fmt = ori_state->output_fmt; + state->encoder_type = ori_state->encoder_type; + state->bg_color = ori_state->bg_color; + state->bpp = ori_state->bpp; + state->sync_enable = ori_state->sync_enable; + state->dither_enable = ori_state->dither_enable; + state->underflow = ori_state->underflow; + + return &state->base; +} + +static void vs_crtc_atomic_destroy_state(struct drm_crtc *crtc, +struct drm_crtc_state *state) +{ + __drm_atomic_helper_crtc_destroy_state(state); + kfree(to_vs_crtc_state(state)); +} + +static int vs_crtc_atomic_set_property(struct drm_crtc *crtc, + struct drm_crtc_state *state, + struct drm_property *property, + uint64_t val) +{ + struct vs_crtc *vs_crtc = to_vs_crtc(crtc); + struct vs_crtc_state *vs_crtc_state = to_vs_crtc_state(state); + + if (property == vs_crtc->sync_mode) + vs_crtc_state->sync_mode = val; + else if (property == vs_crtc->mmu_prefetch) + vs_crtc_state->mmu_prefetch = val; + else if (property == vs_crtc->bg_color) + vs_crtc_state->bg_color = val; + else if (property == vs_crtc->panel_sync) + vs_crtc_state->sync_enable = val; + else if (property == vs_crtc->dither) + vs_crtc_state->dither_enable = val; + else + return -EINVAL; + + return 0; +} + +static int vs_crtc_atomic_get_property(struct drm_crtc *crtc, + const struct drm_crtc_state *state, + struct drm_property *property, + uint64_t *val) +{ + struct vs_crtc *vs_crtc = to_vs_crtc(crtc); + const struct vs_crtc_state *vs_crtc_state = + container_of(state, const struct vs_crtc_state, base); + + if (property == vs_crtc->sync_mode) + *val = vs_crtc_state->sync_mode; + else if (property == vs_crtc->mmu_prefetch) + *v
[PATCH 4/9] drm/verisilicon: Add gem driver for JH7110 SoC
This patch implements gem related APIs for JH7100 SoC. Signed-off-by: Keith Zhao --- drivers/gpu/drm/verisilicon/Makefile | 3 +- drivers/gpu/drm/verisilicon/vs_drv.c | 6 + drivers/gpu/drm/verisilicon/vs_gem.c | 372 +++ drivers/gpu/drm/verisilicon/vs_gem.h | 72 ++ 4 files changed, 452 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/verisilicon/vs_gem.c create mode 100644 drivers/gpu/drm/verisilicon/vs_gem.h diff --git a/drivers/gpu/drm/verisilicon/Makefile b/drivers/gpu/drm/verisilicon/Makefile index 64ce1b26546c..30360e370e47 100644 --- a/drivers/gpu/drm/verisilicon/Makefile +++ b/drivers/gpu/drm/verisilicon/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 -vs_drm-objs := vs_drv.o +vs_drm-objs := vs_drv.o \ + vs_gem.o obj-$(CONFIG_DRM_VERISILICON) += vs_drm.o diff --git a/drivers/gpu/drm/verisilicon/vs_drv.c b/drivers/gpu/drm/verisilicon/vs_drv.c index 24d333598477..e0a2fc43b55f 100644 --- a/drivers/gpu/drm/verisilicon/vs_drv.c +++ b/drivers/gpu/drm/verisilicon/vs_drv.c @@ -30,6 +30,7 @@ #include #include "vs_drv.h" +#include "vs_gem.h" #define DRV_NAME "starfive" #define DRV_DESC "Starfive DRM driver" @@ -47,6 +48,7 @@ static const struct file_operations fops = { .compat_ioctl = drm_compat_ioctl, .poll = drm_poll, .read = drm_read, + .mmap = vs_gem_mmap, }; static struct drm_driver vs_drm_driver = { @@ -54,6 +56,10 @@ static struct drm_driver vs_drm_driver = { .lastclose = drm_fb_helper_lastclose, .prime_handle_to_fd = drm_gem_prime_handle_to_fd, .prime_fd_to_handle = drm_gem_prime_fd_to_handle, + .gem_prime_import = vs_gem_prime_import, + .gem_prime_import_sg_table = vs_gem_prime_import_sg_table, + .gem_prime_mmap = vs_gem_prime_mmap, + .dumb_create= vs_gem_dumb_create, .fops = &fops, .name = DRV_NAME, .desc = DRV_DESC, diff --git a/drivers/gpu/drm/verisilicon/vs_gem.c b/drivers/gpu/drm/verisilicon/vs_gem.c new file mode 100644 index ..3f963471c1ab --- /dev/null +++ b/drivers/gpu/drm/verisilicon/vs_gem.c @@ -0,0 +1,372 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2023 VeriSilicon Holdings Co., Ltd. + */ + +#include +#include +#include + +#include "vs_drv.h" +#include "vs_gem.h" + +static const struct drm_gem_object_funcs vs_gem_default_funcs; + +static int vs_gem_alloc_buf(struct vs_gem_object *vs_obj) +{ + struct drm_device *dev = vs_obj->base.dev; + unsigned int nr_pages; + struct sg_table sgt; + int ret = -ENOMEM; + + if (vs_obj->dma_addr) { + DRM_DEV_DEBUG_KMS(dev->dev, "already allocated.\n"); + return 0; + } + + vs_obj->dma_attrs = DMA_ATTR_WRITE_COMBINE | DMA_ATTR_FORCE_CONTIGUOUS + | DMA_ATTR_NO_KERNEL_MAPPING; + + nr_pages = vs_obj->size >> PAGE_SHIFT; + + vs_obj->pages = kvmalloc_array(nr_pages, sizeof(struct page *), + GFP_KERNEL | __GFP_ZERO); + if (!vs_obj->pages) { + DRM_DEV_ERROR(dev->dev, "failed to allocate pages.\n"); + return -ENOMEM; + } + + vs_obj->cookie = dma_alloc_attrs(to_dma_dev(dev), vs_obj->size, +&vs_obj->dma_addr, GFP_KERNEL, +vs_obj->dma_attrs); + + if (!vs_obj->cookie) { + DRM_DEV_ERROR(dev->dev, "failed to allocate buffer.\n"); + goto err_free; + } + + vs_obj->iova = vs_obj->dma_addr; + + ret = dma_get_sgtable_attrs(to_dma_dev(dev), &sgt, + vs_obj->cookie, vs_obj->dma_addr, + vs_obj->size, vs_obj->dma_attrs); + if (ret < 0) { + DRM_DEV_ERROR(dev->dev, "failed to get sgtable.\n"); + goto err_mem_free; + } + + if (drm_prime_sg_to_page_array(&sgt, vs_obj->pages, nr_pages)) { + DRM_DEV_ERROR(dev->dev, "invalid sgtable.\n"); + ret = -EINVAL; + goto err_sgt_free; + } + + sg_free_table(&sgt); + + return 0; + +err_sgt_free: + sg_free_table(&sgt); +err_mem_free: + dma_free_attrs(to_dma_dev(dev), vs_obj->size, vs_obj->cookie, + vs_obj->dma_addr, vs_obj->dma_attrs); +err_free: + kvfree(vs_obj->pages); + + return ret; +} + +static void vs_gem_free_buf(struct vs_gem_object *vs_obj) +{ + struct drm_device *dev = v
[PATCH 7/9] drm/verisilicon: Add drm plane funcs
Implement plane functions for the DRM driver. Signed-off-by: Keith Zhao --- drivers/gpu/drm/verisilicon/Makefile | 3 +- drivers/gpu/drm/verisilicon/vs_plane.c | 440 + drivers/gpu/drm/verisilicon/vs_plane.h | 74 + 3 files changed, 516 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/verisilicon/vs_plane.c create mode 100644 drivers/gpu/drm/verisilicon/vs_plane.h diff --git a/drivers/gpu/drm/verisilicon/Makefile b/drivers/gpu/drm/verisilicon/Makefile index bae5fbab9bbb..d96ad9399fc7 100644 --- a/drivers/gpu/drm/verisilicon/Makefile +++ b/drivers/gpu/drm/verisilicon/Makefile @@ -3,7 +3,8 @@ vs_drm-objs := vs_drv.o \ vs_crtc.o \ vs_fb.o \ - vs_gem.o + vs_gem.o \ + vs_plane.o obj-$(CONFIG_DRM_VERISILICON) += vs_drm.o diff --git a/drivers/gpu/drm/verisilicon/vs_plane.c b/drivers/gpu/drm/verisilicon/vs_plane.c new file mode 100644 index ..7b0dcef232ae --- /dev/null +++ b/drivers/gpu/drm/verisilicon/vs_plane.c @@ -0,0 +1,440 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2023 VeriSilicon Holdings Co., Ltd. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "vs_crtc.h" +#include "vs_fb.h" +#include "vs_gem.h" +#include "vs_plane.h" +#include "vs_type.h" + +void vs_plane_destory(struct drm_plane *plane) +{ + struct vs_plane *vs_plane = to_vs_plane(plane); + + drm_plane_cleanup(plane); + kfree(vs_plane); +} + +static void vs_plane_reset(struct drm_plane *plane) +{ + struct vs_plane_state *state; + struct vs_plane *vs_plane = to_vs_plane(plane); + + if (plane->state) { + __drm_atomic_helper_plane_destroy_state(plane->state); + + state = to_vs_plane_state(plane->state); + kfree(state); + plane->state = NULL; + } + + state = kzalloc(sizeof(*state), GFP_KERNEL); + if (!state) + return; + + __drm_atomic_helper_plane_reset(plane, &state->base); + + state->degamma = VS_DEGAMMA_DISABLE; + state->degamma_changed = false; + state->base.zpos = vs_plane->id; + + memset(&state->status, 0, sizeof(state->status)); +} + +static void _vs_plane_duplicate_blob(struct vs_plane_state *state, +struct vs_plane_state *ori_state) +{ + state->watermark = ori_state->watermark; + state->color_mgmt = ori_state->color_mgmt; + state->roi = ori_state->roi; + + if (state->watermark) + drm_property_blob_get(state->watermark); + if (state->color_mgmt) + drm_property_blob_get(state->color_mgmt); + if (state->roi) + drm_property_blob_get(state->roi); +} + +static int +_vs_plane_set_property_blob_from_id(struct drm_device *dev, + struct drm_property_blob **blob, + u64 blob_id, + size_t expected_size) +{ + struct drm_property_blob *new_blob = NULL; + + if (blob_id) { + new_blob = drm_property_lookup_blob(dev, blob_id); + if (!new_blob) + return -EINVAL; + + if (new_blob->length != expected_size) { + drm_property_blob_put(new_blob); + return -EINVAL; + } + } + + drm_property_replace_blob(blob, new_blob); + drm_property_blob_put(new_blob); + + return 0; +} + +static struct drm_plane_state * +vs_plane_atomic_duplicate_state(struct drm_plane *plane) +{ + struct vs_plane_state *ori_state; + struct vs_plane_state *state; + + if (WARN_ON(!plane->state)) + return NULL; + + ori_state = to_vs_plane_state(plane->state); + state = kzalloc(sizeof(*state), GFP_KERNEL); + if (!state) + return NULL; + + __drm_atomic_helper_plane_duplicate_state(plane, &state->base); + + state->degamma = ori_state->degamma; + state->degamma_changed = ori_state->degamma_changed; + + _vs_plane_duplicate_blob(state, ori_state); + memcpy(&state->status, &ori_state->status, sizeof(ori_state->status)); + + return &state->base; +} + +static void vs_plane_atomic_destroy_state(struct drm_plane *plane, + struct drm_plane_state *state) +{ + struct vs_plane_state *vs_plane_state = to_vs_plane_state(state); + + __drm_atomic_helper_plane_destroy_state(state); + + drm_property_blob_put(vs_plane_state->watermark); + drm_property_blob_put(vs_plane_state->color_mgmt); + drm_property_blob_put(vs_plane
[PATCH 0/9] Add DRM driver for StarFive SoC JH7110
Hi, This series is a DRM driver for StarFive SoC JH7110, which includes a display controller driver for Verisilicon DC8200 and an HMDI driver. We use GEM framework for buffer management and allocate memory by using DMA APIs. The JH7110 display subsystem includes a display controller Verisilicon DC8200 and an HDMI transmitter. The HDMI TX IP is designed for transmitting video and audio data from DC8200 to a display device. The HDMI TX IP consists of the digital controller and the physical layer. This series does not support HDMI audio driver. Keith Zhao (9): dt-bindings: display: Add yamls for JH7110 display subsystem riscv: dts: starfive: jh7110: add dc&hdmi controller node drm/verisilicon: Add basic drm driver drm/verisilicon: Add gem driver for JH7110 SoC drm/verisilicon: Add mode config funcs drm/verisilicon: Add drm crtc funcs drm/verisilicon: Add drm plane funcs drm/verisilicon: Add verisilicon dc controller driver drm/verisilicon: Add starfive hdmi driver .../display/verisilicon/starfive-hdmi.yaml| 93 + .../display/verisilicon/verisilicon-dc.yaml | 110 + .../display/verisilicon/verisilicon-drm.yaml | 42 + .../devicetree/bindings/vendor-prefixes.yaml |2 + MAINTAINERS |9 + .../jh7110-starfive-visionfive-2.dtsi | 87 + arch/riscv/boot/dts/starfive/jh7110.dtsi | 46 + drivers/gpu/drm/Kconfig |2 + drivers/gpu/drm/Makefile |1 + drivers/gpu/drm/verisilicon/Kconfig | 24 + drivers/gpu/drm/verisilicon/Makefile | 13 + drivers/gpu/drm/verisilicon/starfive_hdmi.c | 928 drivers/gpu/drm/verisilicon/starfive_hdmi.h | 296 +++ drivers/gpu/drm/verisilicon/vs_crtc.c | 388 drivers/gpu/drm/verisilicon/vs_crtc.h | 74 + drivers/gpu/drm/verisilicon/vs_dc.c | 1040 + drivers/gpu/drm/verisilicon/vs_dc.h | 62 + drivers/gpu/drm/verisilicon/vs_dc_hw.c| 2008 + drivers/gpu/drm/verisilicon/vs_dc_hw.h| 496 drivers/gpu/drm/verisilicon/vs_drv.c | 301 +++ drivers/gpu/drm/verisilicon/vs_drv.h | 52 + drivers/gpu/drm/verisilicon/vs_fb.c | 181 ++ drivers/gpu/drm/verisilicon/vs_fb.h | 15 + drivers/gpu/drm/verisilicon/vs_gem.c | 372 +++ drivers/gpu/drm/verisilicon/vs_gem.h | 72 + drivers/gpu/drm/verisilicon/vs_plane.c| 440 drivers/gpu/drm/verisilicon/vs_plane.h| 74 + drivers/gpu/drm/verisilicon/vs_type.h | 72 + include/uapi/drm/drm_fourcc.h | 83 + include/uapi/drm/vs_drm.h | 50 + 30 files changed, 7433 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/verisilicon/starfive-hdmi.yaml create mode 100644 Documentation/devicetree/bindings/display/verisilicon/verisilicon-dc.yaml create mode 100644 Documentation/devicetree/bindings/display/verisilicon/verisilicon-drm.yaml create mode 100644 drivers/gpu/drm/verisilicon/Kconfig create mode 100644 drivers/gpu/drm/verisilicon/Makefile create mode 100644 drivers/gpu/drm/verisilicon/starfive_hdmi.c create mode 100644 drivers/gpu/drm/verisilicon/starfive_hdmi.h create mode 100644 drivers/gpu/drm/verisilicon/vs_crtc.c create mode 100644 drivers/gpu/drm/verisilicon/vs_crtc.h create mode 100644 drivers/gpu/drm/verisilicon/vs_dc.c create mode 100644 drivers/gpu/drm/verisilicon/vs_dc.h create mode 100644 drivers/gpu/drm/verisilicon/vs_dc_hw.c create mode 100644 drivers/gpu/drm/verisilicon/vs_dc_hw.h create mode 100644 drivers/gpu/drm/verisilicon/vs_drv.c create mode 100644 drivers/gpu/drm/verisilicon/vs_drv.h create mode 100644 drivers/gpu/drm/verisilicon/vs_fb.c create mode 100644 drivers/gpu/drm/verisilicon/vs_fb.h create mode 100644 drivers/gpu/drm/verisilicon/vs_gem.c create mode 100644 drivers/gpu/drm/verisilicon/vs_gem.h create mode 100644 drivers/gpu/drm/verisilicon/vs_plane.c create mode 100644 drivers/gpu/drm/verisilicon/vs_plane.h create mode 100644 drivers/gpu/drm/verisilicon/vs_type.h create mode 100644 include/uapi/drm/vs_drm.h -- 2.34.1
[PATCH 3/9] drm/verisilicon: Add basic drm driver
Add a basic platform driver of the DRM driver for JH7110 SoC. Signed-off-by: Keith Zhao --- MAINTAINERS | 2 + drivers/gpu/drm/Kconfig | 2 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/verisilicon/Kconfig | 13 ++ drivers/gpu/drm/verisilicon/Makefile | 6 + drivers/gpu/drm/verisilicon/vs_drv.c | 284 +++ drivers/gpu/drm/verisilicon/vs_drv.h | 48 + include/uapi/drm/drm_fourcc.h| 83 include/uapi/drm/vs_drm.h| 50 + 9 files changed, 489 insertions(+) create mode 100644 drivers/gpu/drm/verisilicon/Kconfig create mode 100644 drivers/gpu/drm/verisilicon/Makefile create mode 100644 drivers/gpu/drm/verisilicon/vs_drv.c create mode 100644 drivers/gpu/drm/verisilicon/vs_drv.h create mode 100644 include/uapi/drm/vs_drm.h diff --git a/MAINTAINERS b/MAINTAINERS index 293aa13d484c..da5b6766a7bb 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7055,6 +7055,8 @@ L:dri-devel@lists.freedesktop.org S: Maintained T: git git://anongit.freedesktop.org/drm/drm-misc F: Documentation/devicetree/bindings/display/verisilicon/ +F: drivers/gpu/drm/verisilicon/ +F: include/uapi/drm/vs_drm.h DRM DRIVERS FOR VIVANTE GPU IP M: Lucas Stach diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index ba3fb04bb691..f7e461fa4656 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -371,6 +371,8 @@ source "drivers/gpu/drm/solomon/Kconfig" source "drivers/gpu/drm/sprd/Kconfig" +source "drivers/gpu/drm/verisilicon/Kconfig" + config DRM_HYPERV tristate "DRM Support for Hyper-V synthetic video device" depends on DRM && PCI && MMU && HYPERV diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index a33257d2bc7f..e50622ee4e46 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -194,3 +194,4 @@ obj-y += gud/ obj-$(CONFIG_DRM_HYPERV) += hyperv/ obj-y += solomon/ obj-$(CONFIG_DRM_SPRD) += sprd/ +obj-$(CONFIG_DRM_VERISILICON) += verisilicon/ diff --git a/drivers/gpu/drm/verisilicon/Kconfig b/drivers/gpu/drm/verisilicon/Kconfig new file mode 100644 index ..89d12185f73b --- /dev/null +++ b/drivers/gpu/drm/verisilicon/Kconfig @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-2.0 + +config DRM_VERISILICON + tristate "DRM Support for VeriSilicon" + depends on DRM + select DRM_KMS_HELPER + select CMA + select DMA_CMA + help + Choose this option if you have a VeriSilicon soc chipset. + This driver provides VeriSilicon kernel mode + setting and buffer management. It does not + provide 2D or 3D acceleration. diff --git a/drivers/gpu/drm/verisilicon/Makefile b/drivers/gpu/drm/verisilicon/Makefile new file mode 100644 index ..64ce1b26546c --- /dev/null +++ b/drivers/gpu/drm/verisilicon/Makefile @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0 + +vs_drm-objs := vs_drv.o + +obj-$(CONFIG_DRM_VERISILICON) += vs_drm.o + diff --git a/drivers/gpu/drm/verisilicon/vs_drv.c b/drivers/gpu/drm/verisilicon/vs_drv.c new file mode 100644 index ..24d333598477 --- /dev/null +++ b/drivers/gpu/drm/verisilicon/vs_drv.c @@ -0,0 +1,284 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2023 VeriSilicon Holdings Co., Ltd. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "vs_drv.h" + +#define DRV_NAME "starfive" +#define DRV_DESC "Starfive DRM driver" +#define DRV_DATE "202305161" +#define DRV_MAJOR 1 +#define DRV_MINOR 0 + +static struct platform_driver vs_drm_platform_driver; + +static const struct file_operations fops = { + .owner = THIS_MODULE, + .open = drm_open, + .release= drm_release, + .unlocked_ioctl = drm_ioctl, + .compat_ioctl = drm_compat_ioctl, + .poll = drm_poll, + .read = drm_read, +}; + +static struct drm_driver vs_drm_driver = { + .driver_features= DRIVER_MODESET | DRIVER_ATOMIC | DRIVER_GEM, + .lastclose = drm_fb_helper_lastclose, + .prime_handle_to_fd = drm_gem_prime_handle_to_fd, + .prime_fd_to_handle = drm_gem_prime_fd_to_handle, + .fops = &fops, + .name = DRV_NAME, + .desc = DRV_DESC, + .date = DRV_DATE, + .major = DRV_MAJOR, + .minor = DRV_MINOR, +}; + +vo
[PATCH 1/9] dt-bindings: display: Add yamls for JH7110 display subsystem
Add bindings for JH7110 display subsystem which has a display controller verisilicon dc8200 and an HDMI interface. Signed-off-by: Keith Zhao --- .../display/verisilicon/starfive-hdmi.yaml| 93 +++ .../display/verisilicon/verisilicon-dc.yaml | 110 ++ .../display/verisilicon/verisilicon-drm.yaml | 42 +++ .../devicetree/bindings/vendor-prefixes.yaml | 2 + MAINTAINERS | 7 ++ 5 files changed, 254 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/verisilicon/starfive-hdmi.yaml create mode 100644 Documentation/devicetree/bindings/display/verisilicon/verisilicon-dc.yaml create mode 100644 Documentation/devicetree/bindings/display/verisilicon/verisilicon-drm.yaml diff --git a/Documentation/devicetree/bindings/display/verisilicon/starfive-hdmi.yaml b/Documentation/devicetree/bindings/display/verisilicon/starfive-hdmi.yaml new file mode 100644 index ..c30b7954a355 --- /dev/null +++ b/Documentation/devicetree/bindings/display/verisilicon/starfive-hdmi.yaml @@ -0,0 +1,93 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/verisilicon/starfive-hdmi.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: StarFive HDMI transmiter + +description: + The StarFive SoC uses the HDMI signal transmiter based on innosilicon IP + to generate HDMI signal from its input and transmit the signal to the screen. + +maintainers: + - Keith Zhao + - ShengYang Chen + +properties: + compatible: +const: starfive,hdmi + + reg: +minItems: 1 + + interrupts: +items: + - description: The HDMI hot plug detection interrupt. + + clocks: +items: + - description: System clock of HDMI module. + - description: Mclk clock of HDMI audio. + - description: Bclk clock of HDMI audio. + - description: Pixel clock generated by HDMI module. + + clock-names: +items: + - const: sysclk + - const: mclk + - const: bclk + - const: pclk + + resets: +items: + - description: Reset for HDMI module. + + reset-names: +items: + - const: hdmi_tx + + '#sound-dai-cells': +const: 0 + + port: +$ref: /schemas/graph.yaml#/properties/port +description: + Port node with one endpoint connected to a display connector node. + +required: + - compatible + - reg + - interrupts + - clocks + - clock-names + - resets + - reset-names + - '#sound-dai-cells' + - port + +additionalProperties: false + +examples: + - | +hdmi: hdmi@2959 { + compatible = "starfive,hdmi"; + reg = <0x2959 0x4000>; + interrupts = <99>; + clocks = <&voutcrg 17>, + <&voutcrg 15>, + <&voutcrg 16>, + <&hdmitx0_pixelclk>; + clock-names = "sysclk", "mclk","bclk","pclk"; + resets = <&voutcrg 9>; + reset-names = "hdmi_tx"; + #sound-dai-cells = <0>; + hdmi_in: port { + #address-cells = <1>; + #size-cells = <0>; + hdmi_input: endpoint@0 { +reg = <0>; +remote-endpoint = <&dc_out_dpi0>; + }; + }; +}; diff --git a/Documentation/devicetree/bindings/display/verisilicon/verisilicon-dc.yaml b/Documentation/devicetree/bindings/display/verisilicon/verisilicon-dc.yaml new file mode 100644 index ..1322502c4cde --- /dev/null +++ b/Documentation/devicetree/bindings/display/verisilicon/verisilicon-dc.yaml @@ -0,0 +1,110 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/verisilicon/verisilicon-dc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: StarFive display controller + +description: + The StarFive SoC uses the display controller based on Verisilicon IP + to transfer the image data from a video memory + buffer to an external LCD interface. + +maintainers: + - Keith Zhao + - ShengYang Chen + +properties: + compatible: +const: verisilicon,dc8200 + + reg: +maxItems: 3 + + interrupts: +items: + - description: The interrupt will be generated when DC finish one frame + + clocks: +items: + - description: Clock for display system noc bus. + - description: Pixel clock for display channel 0. + - description: Pixel clock for display channel 1. + - description: Clock for axi interface of display controller. + - description: Core clock for display controller. + - description: Clock for ahb interface of display controller. + - description: External HDMI pixel clock. + - description: Parent clock for pixel clock + + clock-names: +items: + - const: clk_vout_noc_disp + - const: clk_v
[PATCH 5/9] drm/verisilicon: Add mode config funcs
Add mode setting functions for JH7110 SoC. Signed-off-by: Keith Zhao --- drivers/gpu/drm/verisilicon/Makefile | 1 + drivers/gpu/drm/verisilicon/vs_drv.c | 3 + drivers/gpu/drm/verisilicon/vs_fb.c | 181 +++ drivers/gpu/drm/verisilicon/vs_fb.h | 15 +++ 4 files changed, 200 insertions(+) create mode 100644 drivers/gpu/drm/verisilicon/vs_fb.c create mode 100644 drivers/gpu/drm/verisilicon/vs_fb.h diff --git a/drivers/gpu/drm/verisilicon/Makefile b/drivers/gpu/drm/verisilicon/Makefile index 30360e370e47..38254dc5d98d 100644 --- a/drivers/gpu/drm/verisilicon/Makefile +++ b/drivers/gpu/drm/verisilicon/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 vs_drm-objs := vs_drv.o \ + vs_fb.o \ vs_gem.o obj-$(CONFIG_DRM_VERISILICON) += vs_drm.o diff --git a/drivers/gpu/drm/verisilicon/vs_drv.c b/drivers/gpu/drm/verisilicon/vs_drv.c index e0a2fc43b55f..d84aacd751bc 100644 --- a/drivers/gpu/drm/verisilicon/vs_drv.c +++ b/drivers/gpu/drm/verisilicon/vs_drv.c @@ -30,6 +30,7 @@ #include #include "vs_drv.h" +#include "vs_fb.h" #include "vs_gem.h" #define DRV_NAME "starfive" @@ -118,6 +119,8 @@ static int vs_drm_bind(struct device *dev) if (ret) goto err_mode; + vs_mode_config_init(drm_dev); + ret = drm_vblank_init(drm_dev, drm_dev->mode_config.num_crtc); if (ret) goto err_bind; diff --git a/drivers/gpu/drm/verisilicon/vs_fb.c b/drivers/gpu/drm/verisilicon/vs_fb.c new file mode 100644 index ..3e85f7365084 --- /dev/null +++ b/drivers/gpu/drm/verisilicon/vs_fb.c @@ -0,0 +1,181 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2023 VeriSilicon Holdings Co., Ltd. + */ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "vs_fb.h" +#include "vs_gem.h" + +#define fourcc_mod_vs_get_type(val) \ + (((val) & DRM_FORMAT_MOD_VS_TYPE_MASK) >> 54) + +static struct drm_framebuffer_funcs vs_fb_funcs = { + .create_handle = drm_gem_fb_create_handle, + .destroy= drm_gem_fb_destroy, + .dirty = drm_atomic_helper_dirtyfb, +}; + +static struct drm_framebuffer * +vs_fb_alloc(struct drm_device *dev, const struct drm_mode_fb_cmd2 *mode_cmd, + struct vs_gem_object **obj, unsigned int num_planes) +{ + struct drm_framebuffer *fb; + int ret, i; + + fb = kzalloc(sizeof(*fb), GFP_KERNEL); + if (!fb) + return ERR_PTR(-ENOMEM); + + drm_helper_mode_fill_fb_struct(dev, fb, mode_cmd); + + for (i = 0; i < num_planes; i++) + fb->obj[i] = &obj[i]->base; + + ret = drm_framebuffer_init(dev, fb, &vs_fb_funcs); + if (ret) { + dev_err(dev->dev, "Failed to initialize framebuffer: %d\n", + ret); + kfree(fb); + return ERR_PTR(ret); + } + + return fb; +} + +static struct drm_framebuffer *vs_fb_create(struct drm_device *dev, + struct drm_file *file_priv, + const struct drm_mode_fb_cmd2 *mode_cmd) +{ + struct drm_framebuffer *fb; + const struct drm_format_info *info; + struct vs_gem_object *objs[MAX_NUM_PLANES]; + struct drm_gem_object *obj; + unsigned int height, size; + unsigned char i, num_planes; + int ret = 0; + + info = drm_get_format_info(dev, mode_cmd); + if (!info) + return ERR_PTR(-EINVAL); + + num_planes = info->num_planes; + if (num_planes > MAX_NUM_PLANES) + return ERR_PTR(-EINVAL); + + for (i = 0; i < num_planes; i++) { + obj = drm_gem_object_lookup(file_priv, mode_cmd->handles[i]); + if (!obj) { + dev_err(dev->dev, "Failed to lookup GEM object.\n"); + ret = -ENXIO; + goto err; + } + + height = drm_format_info_plane_height(info, + mode_cmd->height, i); + + size = height * mode_cmd->pitches[i] + mode_cmd->offsets[i]; + + if (obj->size < size) { + drm_gem_object_put(obj); + + ret = -EINVAL; + goto err; + } + + objs[i] = to_vs_gem_object(obj); + } + + fb = vs_fb_alloc(dev, mode_cmd, objs, i); + if (IS_ERR(fb)) { + ret = PTR_ERR(fb); + goto err; + } + + return fb; + +err: + for (; i > 0; i--) + drm_gem_object_put(&objs[i - 1]->base); + + return ERR_PTR(ret); +} + +struct vs_gem_object *vs_fb_get_gem_o
[PATCH 9/9] drm/verisilicon: Add starfive hdmi driver
Add HDMI dirver for StarFive SoC JH7110. Signed-off-by: Keith Zhao --- drivers/gpu/drm/verisilicon/Kconfig | 11 + drivers/gpu/drm/verisilicon/Makefile| 1 + drivers/gpu/drm/verisilicon/starfive_hdmi.c | 928 drivers/gpu/drm/verisilicon/starfive_hdmi.h | 296 +++ drivers/gpu/drm/verisilicon/vs_drv.c| 6 + drivers/gpu/drm/verisilicon/vs_drv.h| 4 + 6 files changed, 1246 insertions(+) create mode 100644 drivers/gpu/drm/verisilicon/starfive_hdmi.c create mode 100644 drivers/gpu/drm/verisilicon/starfive_hdmi.h diff --git a/drivers/gpu/drm/verisilicon/Kconfig b/drivers/gpu/drm/verisilicon/Kconfig index 89d12185f73b..35e85ac41b10 100644 --- a/drivers/gpu/drm/verisilicon/Kconfig +++ b/drivers/gpu/drm/verisilicon/Kconfig @@ -11,3 +11,14 @@ config DRM_VERISILICON This driver provides VeriSilicon kernel mode setting and buffer management. It does not provide 2D or 3D acceleration. + +config STARFIVE_HDMI + bool "Starfive specific extensions HDMI" + help + This selects support for StarFive SoC specific extensions + for the Innosilicon HDMI driver. If you want to enable + HDMI on JH7110 based SoC, you should select this option. + + To compile this driver as a module, choose M here. + + diff --git a/drivers/gpu/drm/verisilicon/Makefile b/drivers/gpu/drm/verisilicon/Makefile index 0ed25b5e3062..ebe2c94f529a 100644 --- a/drivers/gpu/drm/verisilicon/Makefile +++ b/drivers/gpu/drm/verisilicon/Makefile @@ -8,5 +8,6 @@ vs_drm-objs := vs_dc_hw.o \ vs_gem.o \ vs_plane.o +vs_drm-$(CONFIG_STARFIVE_HDMI) += starfive_hdmi.o obj-$(CONFIG_DRM_VERISILICON) += vs_drm.o diff --git a/drivers/gpu/drm/verisilicon/starfive_hdmi.c b/drivers/gpu/drm/verisilicon/starfive_hdmi.c new file mode 100644 index ..128ecca03309 --- /dev/null +++ b/drivers/gpu/drm/verisilicon/starfive_hdmi.c @@ -0,0 +1,928 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2023 StarFive Technology Co., Ltd. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "starfive_hdmi.h" +#include "vs_drv.h" + +static struct starfive_hdmi *encoder_to_hdmi(struct drm_encoder *encoder) +{ + return container_of(encoder, struct starfive_hdmi, encoder); +} + +static struct starfive_hdmi *connector_to_hdmi(struct drm_connector *connector) +{ + return container_of(connector, struct starfive_hdmi, connector); +} + +struct starfive_hdmi_i2c { + struct i2c_adapter adap; + + u8 ddc_addr; + u8 segment_addr; + /* protects the edid data when use i2c cmd to read edid */ + struct mutex lock; + struct completion cmp; +}; + +static const struct pre_pll_config pre_pll_cfg_table[] = { + { 25175000, 25175000, 1, 100, 2, 3, 3, 12, 3, 3, 4, 0, 0xf5}, + { 2520, 2520, 1, 100, 2, 3, 3, 12, 3, 3, 4, 0, 0}, + { 2700, 2700, 1, 90, 3, 2, 2, 10, 3, 3, 4, 0, 0}, + { 27027000, 27027000, 1, 90, 3, 2, 2, 10, 3, 3, 4, 0, 0x170a3d}, + { 2832, 2832, 1, 28, 2, 1, 1, 3, 0, 3, 4, 0, 0x51eb85}, + { 3024, 3024, 1, 30, 2, 1, 1, 3, 0, 3, 4, 0, 0x3d70a3}, + { 3150, 3150, 1, 31, 2, 1, 1, 3, 0, 3, 4, 0, 0x7f}, + { 3375, 3375, 1, 33, 2, 1, 1, 3, 0, 3, 4, 0, 0xcf}, + { 3600, 3600, 1, 36, 2, 1, 1, 3, 0, 3, 4, 0, 0}, + { 4000, 4000, 1, 80, 2, 2, 2, 12, 2, 2, 2, 0, 0}, + { 4697, 4697, 1, 46, 2, 1, 1, 3, 0, 3, 4, 0, 0xf851eb}, + { 4950, 4950, 1, 49, 2, 1, 1, 3, 0, 3, 4, 0, 0x7f}, + { 4900, 4900, 1, 49, 2, 1, 1, 3, 0, 3, 4, 0, 0}, + { 5000, 5000, 1, 50, 2, 1, 1, 3, 0, 3, 4, 0, 0}, + { 5400, 5400, 1, 54, 2, 1, 1, 3, 0, 3, 4, 0, 0}, + { 54054000, 54054000, 1, 54, 2, 1, 1, 3, 0, 3, 4, 0, 0x0dd2f1}, + { 57284000, 57284000, 1, 57, 2, 1, 1, 3, 0, 3, 4, 0, 0x48b439}, + { 5823, 5823, 1, 58, 2, 1, 1, 3, 0, 3, 4, 0, 0x3ae147}, + { 59341000, 59341000, 1, 59, 2, 1, 1, 3, 0, 3, 4, 0, 0x574bc6}, + { 5940, 5940, 1, 99, 3, 1, 1, 1, 3, 3, 4, 0, 0}, + { 6500, 6500, 1, 130, 2, 2, 2, 12, 0, 2, 2, 0, 0}, + { 6825, 6825, 1, 68, 2, 1, 1, 3, 0, 3, 4, 0, 0x3f}, + { 7100, 7100, 1, 71, 2, 1, 1, 3, 0, 3, 4, 0, 0}, + { 74176000, 74176000, 1, 98, 1, 2, 2, 1, 2, 3, 4, 0, 0xe6ae6b}, + { 7425, 7425, 1, 99, 1, 2, 2, 1, 2, 3, 4, 0, 0}, + { 7500, 7500, 1, 75, 2, 1, 1, 3, 0, 3, 4, 0, 0}, + { 7875, 7875, 1, 78, 2, 1, 1, 3, 0, 3, 4, 0, 0xcf}, + { 7950, 7950, 1, 79, 2,
[PATCH 8/9] drm/verisilicon: Add verisilicon dc controller driver
Add DC8200 display controller driver for StarFive JH7110 SoC. Signed-off-by: Keith Zhao --- drivers/gpu/drm/verisilicon/Makefile |4 +- drivers/gpu/drm/verisilicon/vs_dc.c| 1040 drivers/gpu/drm/verisilicon/vs_dc.h| 62 + drivers/gpu/drm/verisilicon/vs_dc_hw.c | 2008 drivers/gpu/drm/verisilicon/vs_dc_hw.h | 496 ++ drivers/gpu/drm/verisilicon/vs_drv.c |2 + 6 files changed, 3611 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/verisilicon/vs_dc.c create mode 100644 drivers/gpu/drm/verisilicon/vs_dc.h create mode 100644 drivers/gpu/drm/verisilicon/vs_dc_hw.c create mode 100644 drivers/gpu/drm/verisilicon/vs_dc_hw.h diff --git a/drivers/gpu/drm/verisilicon/Makefile b/drivers/gpu/drm/verisilicon/Makefile index d96ad9399fc7..0ed25b5e3062 100644 --- a/drivers/gpu/drm/verisilicon/Makefile +++ b/drivers/gpu/drm/verisilicon/Makefile @@ -1,7 +1,9 @@ # SPDX-License-Identifier: GPL-2.0 -vs_drm-objs := vs_drv.o \ +vs_drm-objs := vs_dc_hw.o \ + vs_dc.o \ vs_crtc.o \ + vs_drv.o \ vs_fb.o \ vs_gem.o \ vs_plane.o diff --git a/drivers/gpu/drm/verisilicon/vs_dc.c b/drivers/gpu/drm/verisilicon/vs_dc.c new file mode 100644 index ..a512aaa57f2f --- /dev/null +++ b/drivers/gpu/drm/verisilicon/vs_dc.c @@ -0,0 +1,1040 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2023 VeriSilicon Holdings Co., Ltd. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "vs_crtc.h" +#include "vs_dc_hw.h" +#include "vs_dc.h" +#include "vs_drv.h" +#include "vs_type.h" + +static const char * const vout_clocks[] = { + "clk_vout_noc_disp", + "clk_vout_pix0", + "clk_vout_pix1", + "clk_vout_axi", + "clk_vout_core", + "clk_vout_vout_ahb", + "hdmitx0_pixel", + "clk_vout_dc8200", + +}; + +static const char * const vout_resets[] = { + "rst_vout_axi", + "rst_vout_ahb", + "rst_vout_core", +}; + +static inline void update_format(u32 format, u64 mod, struct dc_hw_fb *fb) +{ + u8 f = FORMAT_A8R8G8B8; + + switch (format) { + case DRM_FORMAT_XRGB: + case DRM_FORMAT_RGBX: + case DRM_FORMAT_XBGR: + case DRM_FORMAT_BGRX: + f = FORMAT_X4R4G4B4; + break; + case DRM_FORMAT_ARGB: + case DRM_FORMAT_RGBA: + case DRM_FORMAT_ABGR: + case DRM_FORMAT_BGRA: + f = FORMAT_A4R4G4B4; + break; + case DRM_FORMAT_XRGB1555: + case DRM_FORMAT_RGBX5551: + case DRM_FORMAT_XBGR1555: + case DRM_FORMAT_BGRX5551: + f = FORMAT_X1R5G5B5; + break; + case DRM_FORMAT_ARGB1555: + case DRM_FORMAT_RGBA5551: + case DRM_FORMAT_ABGR1555: + case DRM_FORMAT_BGRA5551: + f = FORMAT_A1R5G5B5; + break; + case DRM_FORMAT_RGB565: + case DRM_FORMAT_BGR565: + f = FORMAT_R5G6B5; + break; + case DRM_FORMAT_XRGB: + case DRM_FORMAT_RGBX: + case DRM_FORMAT_XBGR: + case DRM_FORMAT_BGRX: + f = FORMAT_X8R8G8B8; + break; + case DRM_FORMAT_ARGB: + case DRM_FORMAT_RGBA: + case DRM_FORMAT_ABGR: + case DRM_FORMAT_BGRA: + f = FORMAT_A8R8G8B8; + break; + case DRM_FORMAT_YUYV: + case DRM_FORMAT_YVYU: + f = FORMAT_YUY2; + break; + case DRM_FORMAT_UYVY: + case DRM_FORMAT_VYUY: + f = FORMAT_UYVY; + break; + case DRM_FORMAT_YUV420: + case DRM_FORMAT_YVU420: + f = FORMAT_YV12; + break; + case DRM_FORMAT_NV21: + f = FORMAT_NV12; + break; + case DRM_FORMAT_NV16: + case DRM_FORMAT_NV61: + f = FORMAT_NV16; + break; + case DRM_FORMAT_P010: + f = FORMAT_P010; + break; + case DRM_FORMAT_ARGB2101010: + case DRM_FORMAT_RGBA1010102: + case DRM_FORMAT_ABGR2101010: + case DRM_FORMAT_BGRA1010102: + f = FORMAT_A2R10G10B10; + break; + case DRM_FORMAT_NV12: + if (fourcc_mod_vs_get_type(mod) == + DRM_FORMAT_MOD_VS_TYPE_CUSTOM_10BIT) + f = FORMAT_NV12_10BIT; + else + f = FORMAT_NV12; + break; + case DRM_FORMAT_YUV444: + if (f
[PATCH 2/9] riscv: dts: starfive: jh7110: add dc&hdmi controller node
Add the dc controller and hdmi node for the Starfive JH7110 SoC. Signed-off-by: Keith Zhao --- .../jh7110-starfive-visionfive-2.dtsi | 87 +++ arch/riscv/boot/dts/starfive/jh7110.dtsi | 46 ++ 2 files changed, 133 insertions(+) diff --git a/arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-2.dtsi b/arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-2.dtsi index 1155b97b593d..8dc6c8a15c59 100644 --- a/arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-2.dtsi +++ b/arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-2.dtsi @@ -31,6 +31,21 @@ memory@4000 { reg = <0x0 0x4000 0x1 0x0>; }; + reserved-memory { + #address-cells = <2>; + #size-cells = <2>; + ranges; + + linux,cma { + compatible = "shared-dma-pool"; + reusable; + size = <0x0 0x2000>; + alignment = <0x0 0x1000>; + alloc-ranges = <0x0 0x8000 0x0 0x2000>; + linux,cma-default; + }; + }; + gpio-restart { compatible = "gpio-restart"; gpios = <&sysgpio 35 GPIO_ACTIVE_HIGH>; @@ -214,6 +229,41 @@ GPOEN_DISABLE, slew-rate = <0>; }; }; + + hdmi_pins: hdmi-0 { + hdmi-scl-pins { + pinmux = ; + input-enable; + bias-pull-up; + }; + + hdmi-sda-pins { + pinmux = ; + input-enable; + bias-pull-up; + }; + + hdmi-cec-pins { + pinmux = ; + input-enable; + bias-pull-up; + }; + + hdmi-hpd-pins { + pinmux = ; + input-enable; + bias-disable; /* external pull-up */ + }; + }; + }; &uart0 { @@ -221,3 +271,40 @@ &uart0 { pinctrl-0 = <&uart0_pins>; status = "okay"; }; + +&voutcrg { + status = "okay"; +}; + +&display { + status = "okay"; +}; + +&hdmi { + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <&hdmi_pins>; + + hdmi_in: port { + #address-cells = <1>; + #size-cells = <0>; + hdmi_input: endpoint@0 { + reg = <0>; + remote-endpoint = <&dc_out_dpi0>; + }; + }; +}; + +&dc8200 { + status = "okay"; + + dc_out: port { + #address-cells = <1>; + #size-cells = <0>; + dc_out_dpi0: endpoint@0 { + reg = <0>; + remote-endpoint = <&hdmi_input>; + }; + + }; +}; diff --git a/arch/riscv/boot/dts/starfive/jh7110.dtsi b/arch/riscv/boot/dts/starfive/jh7110.dtsi index 9acb5fb1716d..66be6e65a066 100644 --- a/arch/riscv/boot/dts/starfive/jh7110.dtsi +++ b/arch/riscv/boot/dts/starfive/jh7110.dtsi @@ -249,6 +249,11 @@ tdm_ext: tdm-ext-clock { #clock-cells = <0>; }; + display: display-subsystem { + compatible = "verisilicon,display-subsystem"; + ports = <&dc_out>; + }; + soc { compatible = "simple-bus"; interrupt-parent = <&plic>; @@ -570,5 +575,46 @@ voutcrg: clock-controller@295c { #reset-cells = <1>; power-domains = <&pwrc JH7110_PD_VOUT>; }; + + dc8200: dc8200@2940 { + compatible = "verisilicon,dc8200"; + reg = <0x0 0x2940 0x0 0x100>, + <0x0 0x29400800 0x0 0x2000>, + <0x0 0x295B 0x0 0x90>; + interrupts = <95>; + clocks = <&syscrg JH7110_SYSCLK_NOC_BUS_DISP_AXI>, + <&voutcrg JH7110_VOUTCLK_DC8200_PIX0>, + <&voutcrg JH7110_VOUTCLK_DC8200_PIX1>, + <&voutcrg JH7110_VOUTCLK_DC8200_AXI>, + <&voutcrg JH7110_VOUTCLK_DC8200_CORE>, + <&voutcrg JH7110_VOUTCLK_DC8200_AHB>, + <&hdmitx0_pixelclk>, +
Re: [PATCH 1/9] dt-bindings: display: Add yamls for JH7110 display subsystem
On 2023/6/7 14:41, Maxime Ripard wrote: > On Tue, Jun 06, 2023 at 11:37:53PM +0100, Conor Dooley wrote: >> On Wed, Jun 07, 2023 at 12:22:33AM +0200, Heiko Stübner wrote: >> > Am Dienstag, 6. Juni 2023, 20:41:17 CEST schrieb Shengyu Qu: >> > > > On Fri, Jun 02, 2023 at 03:40:35PM +0800, Keith Zhao wrote: >> > > >> Add bindings for JH7110 display subsystem which >> > > >> has a display controller verisilicon dc8200 >> > > >> and an HDMI interface. >> >> > > >> +description: >> > > >> + The StarFive SoC uses the HDMI signal transmiter based on >> > > >> innosilicon IP >> > > > Is innosilicon the same thing as verisilicon? Also >> > > > s/transmiter/transmitter/, both here and in the title. yes,innosilicon is the HDMI IP and verisilicon is the DC-controller IP >> > > >> > > I think that is not the same, I remember Rockchip has used a HDMI >> > > transmitter from >> > > >> > > Innosilicon, and there is a existing driver for that in mainline. >> > >> > Yep, I think Innosilicon is the company you turn to when you want to save >> > a bit of money ;-) . In the bigger SoCs Rockchip most of the time uses >> > Designware hdmi blocks and looking at the history only the rk3036 ever >> > used an Innosilicon block. >> > I have done a HDMIcomparison of the rk3036 and the jh7110, and they are both based on ip Innosilicon. the hardware of them . Some parts of the hardware of the two are common, such as the logic of hdmi I2C to obtain edid, and the register definition is consistent. Many registers are defined differently from the linux main line inno driver, including registers that contain specific bits and some registers in linux main line inno driver no longer used in my new inoo hdmi hardware. >> > Looking at the history, 2016 really was a long time ago :-D. >> > >> > > So Keith, if that's true, I think it is better to seperate the HDMI >> > > stuff and reuse existing driver. >> > >> > I'm not so sure about that - at least from a cursory glance :-) . >> > >> > The registers do look slightly different and I don't know how much >> > the IP changed between the rk3036-version and the jh7110 version. >> > >> > At the very least, I know my rk3036 board isn't booting right now, so >> > I can't really provide help for generalizing the rockchip-driver. >> > >> > At the very least both the binding and driver could drop the >> > "starfive-hdmi" >> > and actually use the Innosilicon in the naming somewhere, so that it's >> > clear for future developers :-) >> >> Seeing "based on" always makes me a little bit nervous to be honest when >> it comes to using a compatible from the IP. Is it the IP? What version >> is it? etc. Perhaps "starfive,jh7110-hdmi" & falling back to some sort >> of "innosilicon,hdmi" would be more future/IP-silliness proof. >> Driver can always be generic & bind against "innosilicon,hdmi" until >> that becomes impossible. > > Given that Neil was saying that there's at least two > generations/revisions/models of an HDMI controller from Innosilicon, I'm > not sure that compatible is enough to reach that goal anyway. > > Maxime I will change the the binding to meet innosilicon,hdmi . for the drivers part , I will study the possibility of RK-HDMI reuse. Thank you for your comments
Re: [PATCH 3/9] drm/verisilicon: Add basic drm driver
On 2023/7/4 2:42, Shengyu Qu wrote: > Hello Keith, > > While compiling this driver as a module, a error happens: > > drivers/gpu/drm/verisilicon/vs_drm: struct of_device_id is 200 bytes. The > last of 1 is: > 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 > 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 > 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 > 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 > 0x00 0x00 0x00 0x00 0x76 0x65 0x72 0x69 0x73 0x69 0x6c 0x69 0x63 0x6f 0x6e > 0x2c 0x64 0x69 0x73 0x70 0x6c 0x61 0x79 0x2d 0x73 0x75 0x62 0x73 0x79 0x73 > 0x74 0x65 0x6d 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 > 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 > 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 > 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 > 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 > 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 > 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 > 0x00 0x00 0x00 > 0x00 0x00 > FATAL: modpost: drivers/gpu/drm/verisilicon/vs_drm: struct of_device_id is > not terminated with a NULL entry! > >> + >> +static const struct of_device_id vs_drm_dt_ids[] = { >> + { .compatible = "verisilicon,display-subsystem", }, >> +}; >> + > > So, this should be: > > static const struct of_device_id vs_drm_dt_ids[] = { > { .compatible = "verisilicon,display-subsystem", }, > { }, > }; > > After fixing this problem, another error happens: > > ERROR: modpost: module vs_drm uses symbol dma_buf_mmap from namespace > DMA_BUF, but does not import it. > > Please fix. > > Best regards, > Shengyu hello Shengyu , I can reproduce the error generated by compiling ko , and add MODULE_IMPORT_NS(DMA_BUF) at the beginning of vs_gem.c , it can fix the error message, I will add this in my next patch , thanks
Re: [PATCH 7/9] drm/verisilicon: Add drm plane funcs
On 2023/7/11 0:46, Shengyu Qu wrote: > Hello Keith, >> + >> +static void vs_plane_atomic_update(struct drm_plane *plane, >> + struct drm_atomic_state *state) >> +{ >> + struct drm_plane_state *new_state = >> drm_atomic_get_new_plane_state(state, >> + plane); >> + unsigned char i, num_planes; >> + struct drm_framebuffer *fb; >> + struct vs_plane *vs_plane = to_vs_plane(plane); >> + //struct drm_plane_state *state = plane->state; >> + struct vs_crtc *vs_crtc = to_vs_crtc(new_state->crtc); >> + struct vs_plane_state *plane_state = to_vs_plane_state(new_state); >> + //struct drm_format_name_buf *name = &plane_state->status.format_name; >> + >> + if (!new_state->fb || !new_state->crtc) >> + return; >> + >> + fb = new_state->fb; >> + >> + num_planes = vs_get_plane_number(fb); >> + >> + for (i = 0; i < num_planes; i++) { >> + struct vs_gem_object *vs_obj; >> + >> + vs_obj = vs_fb_get_gem_obj(fb, i); >> + vs_plane->dma_addr[i] = vs_obj->iova + fb->offsets[i]; > > There is a dcache flush operation here in downstream driver. Is that a cache > coherence problem? > > Best regards, > > Shengyu > >> + } >> + >> + plane_state->status.src = drm_plane_state_src(new_state); >> + plane_state->status.dest = drm_plane_state_dest(new_state); >> + >> + vs_plane->funcs->update(vs_crtc->dev, vs_plane, plane, state); >> +} >>yes , You can find that the current situation is very professional. This problem exists at present, but the dma interface is not perfect at now, and the dma_sync_single_for_device interface needs to be implemented later. I will consider repairing this problem in the form of patch
[PATCH v2 6/6] drm/vs: Add hdmi driver
add hdmi driver as encoder and connect Signed-off-by: Keith Zhao --- drivers/gpu/drm/verisilicon/Kconfig | 8 +- drivers/gpu/drm/verisilicon/Makefile| 1 + drivers/gpu/drm/verisilicon/starfive_hdmi.c | 949 drivers/gpu/drm/verisilicon/starfive_hdmi.h | 295 ++ drivers/gpu/drm/verisilicon/vs_drv.c| 5 + drivers/gpu/drm/verisilicon/vs_drv.h| 4 + 6 files changed, 1261 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/verisilicon/starfive_hdmi.c create mode 100644 drivers/gpu/drm/verisilicon/starfive_hdmi.h diff --git a/drivers/gpu/drm/verisilicon/Kconfig b/drivers/gpu/drm/verisilicon/Kconfig index 3a361f8c8..122c786e3 100644 --- a/drivers/gpu/drm/verisilicon/Kconfig +++ b/drivers/gpu/drm/verisilicon/Kconfig @@ -12,4 +12,10 @@ config DRM_VERISILICON setting and buffer management. It does not provide 2D or 3D acceleration. - +config DRM_VERISILICON_STARFIVE_HDMI + bool "Starfive HDMI extensions" + depends on DRM_VERISILICON + help + This selects support for StarFive soc specific extensions + for the Innosilicon HDMI driver. If you want to enable + HDMI on JH7110 based soc, you should select this option. diff --git a/drivers/gpu/drm/verisilicon/Makefile b/drivers/gpu/drm/verisilicon/Makefile index 1d48016ca..08350f25b 100644 --- a/drivers/gpu/drm/verisilicon/Makefile +++ b/drivers/gpu/drm/verisilicon/Makefile @@ -7,5 +7,6 @@ vs_drm-objs := vs_dc_hw.o \ vs_modeset.o \ vs_plane.o +vs_drm-$(CONFIG_DRM_VERISILICON_STARFIVE_HDMI) += starfive_hdmi.o obj-$(CONFIG_DRM_VERISILICON) += vs_drm.o diff --git a/drivers/gpu/drm/verisilicon/starfive_hdmi.c b/drivers/gpu/drm/verisilicon/starfive_hdmi.c new file mode 100644 index 0..d296c4b71 --- /dev/null +++ b/drivers/gpu/drm/verisilicon/starfive_hdmi.c @@ -0,0 +1,949 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2023 StarFive Technology Co., Ltd. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "starfive_hdmi.h" +#include "vs_drv.h" +#include "vs_crtc.h" + +static struct starfive_hdmi *encoder_to_hdmi(struct drm_encoder *encoder) +{ + return container_of(encoder, struct starfive_hdmi, encoder); +} + +static struct starfive_hdmi *connector_to_hdmi(struct drm_connector *connector) +{ + return container_of(connector, struct starfive_hdmi, connector); +} + +struct starfive_hdmi_i2c { + struct i2c_adapter adap; + + u8 ddc_addr; + u8 segment_addr; + /* protects the edid data when use i2c cmd to read edid */ + struct mutex lock; + struct completion cmp; +}; + +static const struct pre_pll_config pre_pll_cfg_table[] = { + { 25175000, 25175000, 1, 100, 2, 3, 3, 12, 3, 3, 4, 0, 0xf5}, + { 2520, 2520, 1, 100, 2, 3, 3, 12, 3, 3, 4, 0, 0}, + { 2700, 2700, 1, 90, 3, 2, 2, 10, 3, 3, 4, 0, 0}, + { 27027000, 27027000, 1, 90, 3, 2, 2, 10, 3, 3, 4, 0, 0x170a3d}, + { 2832, 2832, 1, 28, 2, 1, 1, 3, 0, 3, 4, 0, 0x51eb85}, + { 3024, 3024, 1, 30, 2, 1, 1, 3, 0, 3, 4, 0, 0x3d70a3}, + { 3150, 3150, 1, 31, 2, 1, 1, 3, 0, 3, 4, 0, 0x7f}, + { 3375, 3375, 1, 33, 2, 1, 1, 3, 0, 3, 4, 0, 0xcf}, + { 3600, 3600, 1, 36, 2, 1, 1, 3, 0, 3, 4, 0, 0}, + { 4000, 4000, 1, 80, 2, 2, 2, 12, 2, 2, 2, 0, 0}, + { 4697, 4697, 1, 46, 2, 1, 1, 3, 0, 3, 4, 0, 0xf851eb}, + { 4950, 4950, 1, 49, 2, 1, 1, 3, 0, 3, 4, 0, 0x7f}, + { 4900, 4900, 1, 49, 2, 1, 1, 3, 0, 3, 4, 0, 0}, + { 5000, 5000, 1, 50, 2, 1, 1, 3, 0, 3, 4, 0, 0}, + { 5400, 5400, 1, 54, 2, 1, 1, 3, 0, 3, 4, 0, 0}, + { 54054000, 54054000, 1, 54, 2, 1, 1, 3, 0, 3, 4, 0, 0x0dd2f1}, + { 57284000, 57284000, 1, 57, 2, 1, 1, 3, 0, 3, 4, 0, 0x48b439}, + { 5823, 5823, 1, 58, 2, 1, 1, 3, 0, 3, 4, 0, 0x3ae147}, + { 59341000, 59341000, 1, 59, 2, 1, 1, 3, 0, 3, 4, 0, 0x574bc6}, + { 5940, 5940, 1, 99, 3, 1, 1, 1, 3, 3, 4, 0, 0}, + { 6500, 6500, 1, 130, 2, 2, 2, 12, 0, 2, 2, 0, 0}, + { 6825, 6825, 1, 68, 2, 1, 1, 3, 0, 3, 4, 0, 0x3f}, + { 7100, 7100, 1, 71, 2, 1, 1, 3, 0, 3, 4, 0, 0}, + { 74176000, 74176000, 1, 98, 1, 2, 2, 1, 2, 3, 4, 0, 0xe6ae6b}, + { 7425, 7425, 1, 99, 1, 2, 2, 1, 2, 3, 4, 0, 0}, + { 7500, 7500, 1, 75, 2, 1, 1, 3, 0, 3, 4, 0, 0}, + { 7875, 7875, 1, 78, 2, 1, 1, 3, 0, 3, 4, 0, 0xcf}, + { 7950, 7950, 1, 79, 2, 1, 1, 3, 0
[PATCH v2 1/6] dt-bindings: display: Add yamls for JH7110 display system
StarFive SoCs JH7110 display system: lcd-controller bases verisilicon dc8200 IP, and hdmi bases Innosilicon IP. Add bindings for them. also update MAINTAINERS for dt-bindings about this patch, I tested the dtbs_check and dt_binding_check with the result pass. Based on the feedback of the previous version, the corresponding arrangement is made Signed-off-by: Keith Zhao --- .../starfive/starfive,display-subsystem.yaml | 41 +++ .../starfive/starfive,jh7110-dc8200.yaml | 109 ++ .../starfive/starfive,jh7110-inno-hdmi.yaml | 85 ++ MAINTAINERS | 7 ++ 4 files changed, 242 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/starfive/starfive,display-subsystem.yaml create mode 100644 Documentation/devicetree/bindings/display/starfive/starfive,jh7110-dc8200.yaml create mode 100644 Documentation/devicetree/bindings/display/starfive/starfive,jh7110-inno-hdmi.yaml diff --git a/Documentation/devicetree/bindings/display/starfive/starfive,display-subsystem.yaml b/Documentation/devicetree/bindings/display/starfive/starfive,display-subsystem.yaml new file mode 100644 index 0..f45b97b08 --- /dev/null +++ b/Documentation/devicetree/bindings/display/starfive/starfive,display-subsystem.yaml @@ -0,0 +1,41 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/starfive/starfive,display-subsystem.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Starfive DRM master device + +maintainers: + - Keith Zhao + - ShengYang Chen + +description: + The Starfive DRM master device is a virtual device needed to list all + display controller or other display interface nodes that comprise the + graphics subsystem. + +properties: + compatible: +const: starfive,display-subsystem + + ports: +$ref: /schemas/types.yaml#/definitions/phandle-array +description: + Should contain a list of phandles pointing to display interface ports + of display controller devices. Display controller definitions as defined + in Documentation/devicetree/bindings/display/starfive/ + starfive,jh7110-dc8200.yaml + +required: + - compatible + - ports + +additionalProperties: false + +examples: + - | +display-subsystem { +compatible = "starfive,display-subsystem"; +ports = <&dc_out>; +}; diff --git a/Documentation/devicetree/bindings/display/starfive/starfive,jh7110-dc8200.yaml b/Documentation/devicetree/bindings/display/starfive/starfive,jh7110-dc8200.yaml new file mode 100644 index 0..87051cddf --- /dev/null +++ b/Documentation/devicetree/bindings/display/starfive/starfive,jh7110-dc8200.yaml @@ -0,0 +1,109 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/starfive/starfive,jh7110-dc8200.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: StarFive display controller + +description: + The StarFive SoC uses the display controller based on Verisilicon IP + to transfer the image data from a video memory buffer to an external + LCD interface. + +maintainers: + - Keith Zhao + +properties: + compatible: +const: starfive,jh7110-dc8200 + + reg: +minItems: 1 +items: + - description: + host interface + - description: + display physical base address and length. + + interrupts: +items: + - description: The interrupt will be generated when DC finish one frame + + clocks: +items: + - description: Clock for display system noc bus. + - description: Pixel clock for display channel 0. + - description: Pixel clock for display channel 1. + - description: Core clock for display controller. + - description: Clock for axi bus to access ddr. + - description: Clock for ahb bus to R/W the phy regs. + - description: External HDMI pixel clock. + - description: Parent clock for pixel clock + + clock-names: +items: + - const: noc_bus + - const: channel0 + - const: channel1 + - const: dc_core + - const: axi_core + - const: ahb + - const: hdmi_tx + - const: dc_parent + + resets: +items: + - description: Reset for axi bus. + - description: Reset for ahb bus. + - description: Core reset of display controller. + + reset-names: +items: + - const: axi + - const: ahb + - const: core + + port: +$ref: /schemas/graph.yaml#/properties/port + +required: + - compatible + - reg + - interrupts + - clocks + - clock-names + - resets + - reset-names + - port + +additionalProperties: false + +examples: + - | +dc8200: lcd-controller@2940 { +compatible = "starfive,jh7110-dc8200"; +reg = <0x2940 0x100>, <0x29400800 0x2000>; +interrupts = <95>; +cl
dri-devel@lists.freedesktop.org
add 2 crtcs and 8 planes in vs-drm Signed-off-by: Keith Zhao --- drivers/gpu/drm/verisilicon/Makefile |8 +- drivers/gpu/drm/verisilicon/vs_crtc.c | 257 drivers/gpu/drm/verisilicon/vs_crtc.h | 43 + drivers/gpu/drm/verisilicon/vs_dc.c| 1002 drivers/gpu/drm/verisilicon/vs_dc.h| 80 + drivers/gpu/drm/verisilicon/vs_dc_hw.c | 1959 drivers/gpu/drm/verisilicon/vs_dc_hw.h | 492 ++ drivers/gpu/drm/verisilicon/vs_drv.c |2 + drivers/gpu/drm/verisilicon/vs_plane.c | 526 +++ drivers/gpu/drm/verisilicon/vs_plane.h | 58 + drivers/gpu/drm/verisilicon/vs_type.h | 69 + 11 files changed, 4494 insertions(+), 2 deletions(-) create mode 100644 drivers/gpu/drm/verisilicon/vs_crtc.c create mode 100644 drivers/gpu/drm/verisilicon/vs_crtc.h create mode 100644 drivers/gpu/drm/verisilicon/vs_dc.c create mode 100644 drivers/gpu/drm/verisilicon/vs_dc.h create mode 100644 drivers/gpu/drm/verisilicon/vs_dc_hw.c create mode 100644 drivers/gpu/drm/verisilicon/vs_dc_hw.h create mode 100644 drivers/gpu/drm/verisilicon/vs_plane.c create mode 100644 drivers/gpu/drm/verisilicon/vs_plane.h create mode 100644 drivers/gpu/drm/verisilicon/vs_type.h diff --git a/drivers/gpu/drm/verisilicon/Makefile b/drivers/gpu/drm/verisilicon/Makefile index 7d3be305b..1d48016ca 100644 --- a/drivers/gpu/drm/verisilicon/Makefile +++ b/drivers/gpu/drm/verisilicon/Makefile @@ -1,7 +1,11 @@ # SPDX-License-Identifier: GPL-2.0 -vs_drm-objs := vs_drv.o \ - vs_modeset.o +vs_drm-objs := vs_dc_hw.o \ + vs_dc.o \ + vs_crtc.o \ + vs_drv.o \ + vs_modeset.o \ + vs_plane.o obj-$(CONFIG_DRM_VERISILICON) += vs_drm.o diff --git a/drivers/gpu/drm/verisilicon/vs_crtc.c b/drivers/gpu/drm/verisilicon/vs_crtc.c new file mode 100644 index 0..8a658ea77 --- /dev/null +++ b/drivers/gpu/drm/verisilicon/vs_crtc.c @@ -0,0 +1,257 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2023 VeriSilicon Holdings Co., Ltd. + * + */ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "vs_crtc.h" +#include "vs_dc.h" +#include "vs_drv.h" + +static void vs_crtc_reset(struct drm_crtc *crtc) +{ + struct vs_crtc_state *state; + + if (crtc->state) { + __drm_atomic_helper_crtc_destroy_state(crtc->state); + + state = to_vs_crtc_state(crtc->state); + kfree(state); + crtc->state = NULL; + } + + state = kzalloc(sizeof(*state), GFP_KERNEL); + if (!state) + return; + + __drm_atomic_helper_crtc_reset(crtc, &state->base); +} + +static struct drm_crtc_state * +vs_crtc_atomic_duplicate_state(struct drm_crtc *crtc) +{ + struct vs_crtc_state *ori_state; + struct vs_crtc_state *state; + + if (!crtc->state) + return NULL; + + ori_state = to_vs_crtc_state(crtc->state); + state = kzalloc(sizeof(*state), GFP_KERNEL); + if (!state) + return NULL; + + __drm_atomic_helper_crtc_duplicate_state(crtc, &state->base); + + state->output_fmt = ori_state->output_fmt; + state->encoder_type = ori_state->encoder_type; + state->bpp = ori_state->bpp; + state->underflow = ori_state->underflow; + + return &state->base; +} + +static void vs_crtc_atomic_destroy_state(struct drm_crtc *crtc, +struct drm_crtc_state *state) +{ + __drm_atomic_helper_crtc_destroy_state(state); + kfree(to_vs_crtc_state(state)); +} + +static int vs_crtc_enable_vblank(struct drm_crtc *crtc) +{ + struct vs_crtc *vs_crtc = to_vs_crtc(crtc); + struct vs_dc *dc = dev_get_drvdata(vs_crtc->dev); + + vs_dc_enable_vblank(dc, true); + + return 0; +} + +static void vs_crtc_disable_vblank(struct drm_crtc *crtc) +{ + struct vs_crtc *vs_crtc = to_vs_crtc(crtc); + struct vs_dc *dc = dev_get_drvdata(vs_crtc->dev); + + vs_dc_enable_vblank(dc, false); +} + +static const struct drm_crtc_funcs vs_crtc_funcs = { + .set_config = drm_atomic_helper_set_config, + .page_flip = drm_atomic_helper_page_flip, + .reset = vs_crtc_reset, + .atomic_duplicate_state = vs_crtc_atomic_duplicate_state, + .atomic_destroy_state = vs_crtc_atomic_destroy_state, + .enable_vblank = vs_crtc_enable_vblank, + .disable_vblank = vs_crtc_disable_vblank, +}; + +static u8 cal_pixel_bits(u32 bus_format) +{ + u8 bpp; + + switch (bus_format) { + case MEDIA_BUS_FMT_RGB565_1X16: + case MEDIA_BUS_FMT_UYVY8_1X16: + bpp = 16; + break; + case MEDIA_BUS_FMT_RGB666_1X18: + case MEDIA_BUS_FMT_RGB666_1
[PATCH v2 4/6] drm/vs: Register DRM device
Implement drm device registration interface Thomas Zimmermann wrote: You are replacing almost all of the GEM DMA object's helper code. Either inherit directly from drm_gem_object drop the dependency entirely, or you could try to fit your code into GEM DMA as well Eventually I found an answer and it was DRM_GEM_DMA_DRIVER_OPS_WITH_DUMB_CREATE After I adapt this interface, the custom gem logic interfaces can be deleted. It's a big shocking, clap! Signed-off-by: Keith Zhao --- drivers/gpu/drm/Kconfig | 2 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/verisilicon/Kconfig | 15 ++ drivers/gpu/drm/verisilicon/Makefile | 7 + drivers/gpu/drm/verisilicon/vs_drv.c | 227 +++ drivers/gpu/drm/verisilicon/vs_drv.h | 27 +++ drivers/gpu/drm/verisilicon/vs_modeset.c | 36 drivers/gpu/drm/verisilicon/vs_modeset.h | 10 + include/uapi/drm/vs_drm.h| 50 + 9 files changed, 375 insertions(+) create mode 100644 drivers/gpu/drm/verisilicon/Kconfig create mode 100644 drivers/gpu/drm/verisilicon/Makefile create mode 100644 drivers/gpu/drm/verisilicon/vs_drv.c create mode 100644 drivers/gpu/drm/verisilicon/vs_drv.h create mode 100644 drivers/gpu/drm/verisilicon/vs_modeset.c create mode 100644 drivers/gpu/drm/verisilicon/vs_modeset.h create mode 100644 include/uapi/drm/vs_drm.h diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index afb3b2f5f..9ede80ef9 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -363,6 +363,8 @@ source "drivers/gpu/drm/solomon/Kconfig" source "drivers/gpu/drm/sprd/Kconfig" +source "drivers/gpu/drm/verisilicon/Kconfig" + config DRM_HYPERV tristate "DRM Support for Hyper-V synthetic video device" depends on DRM && PCI && MMU && HYPERV diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index 7a09a89b4..6db3bc397 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -194,3 +194,4 @@ obj-y += gud/ obj-$(CONFIG_DRM_HYPERV) += hyperv/ obj-y += solomon/ obj-$(CONFIG_DRM_SPRD) += sprd/ +obj-$(CONFIG_DRM_VERISILICON) += verisilicon/ diff --git a/drivers/gpu/drm/verisilicon/Kconfig b/drivers/gpu/drm/verisilicon/Kconfig new file mode 100644 index 0..3a361f8c8 --- /dev/null +++ b/drivers/gpu/drm/verisilicon/Kconfig @@ -0,0 +1,15 @@ +# SPDX-License-Identifier: GPL-2.0 +config DRM_VERISILICON + tristate "DRM Support for VeriSilicon" + depends on DRM + select DRM_KMS_HELPER + select DRM_GEM_DMA_HELPER + select CMA + select DMA_CMA + help + Choose this option if you have a VeriSilicon soc chipset. + This driver provides VeriSilicon kernel mode + setting and buffer management. It does not + provide 2D or 3D acceleration. + + diff --git a/drivers/gpu/drm/verisilicon/Makefile b/drivers/gpu/drm/verisilicon/Makefile new file mode 100644 index 0..7d3be305b --- /dev/null +++ b/drivers/gpu/drm/verisilicon/Makefile @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0 + +vs_drm-objs := vs_drv.o \ + vs_modeset.o + +obj-$(CONFIG_DRM_VERISILICON) += vs_drm.o + diff --git a/drivers/gpu/drm/verisilicon/vs_drv.c b/drivers/gpu/drm/verisilicon/vs_drv.c new file mode 100644 index 0..da7698c3d --- /dev/null +++ b/drivers/gpu/drm/verisilicon/vs_drv.c @@ -0,0 +1,227 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2023 VeriSilicon Holdings Co., Ltd. + */ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "vs_drv.h" +#include "vs_modeset.h" + +#define DRV_NAME "verisilicon" +#define DRV_DESC "Verisilicon DRM driver" +#define DRV_DATE "20230516" +#define DRV_MAJOR 1 +#define DRV_MINOR 0 + +static int vs_gem_dumb_create(struct drm_file *file, struct drm_device *dev, + struct drm_mode_create_dumb *args) +{ + struct vs_drm_device *priv = to_vs_drm_private(dev); + + unsigned int pitch = DIV_ROUND_UP(args->width * args->bpp, 8); + + if (args->bpp % 10) + args->pitch = ALIGN(pitch, priv->pitch_alignment); + else + /* for costum 10bit format with no bit gaps */ + args->pitch = pitch; + + return drm_gem_dma_dumb_create_internal(file, dev, args); +} + +DEFINE_DRM_GEM_FOPS(vs_drm_fops); + +static struct drm_driver vs_drm_driver = { + .driver_features= DRIVER_MODESET | DRIVER_ATOMIC | DRIVER_GEM, + + DRM_GEM_DMA_DRIVER_OPS_WITH_DUMB_CREATE(vs_gem_dumb_create), + + .fops = &vs_drm_fops, + .name = D
[PATCH v2 0/6] DRM driver for verisilicon
This patch is a drm driver for Starfive Soc JH7110, I am sending Drm driver part and HDMI driver part. We used GEM framework for buffer management , and for buffer allocation,we use DMA APIs. the Starfive HDMI servers as interface between a LCD Controller and a HDMI bus. A HDMI TX consists of one HDMI transmitter controller and one HDMI transmitter PHY. (Sound support is not include in this patch) This patchset should be applied after the patchset: https://patchwork.kernel.org/project/linux-clk/cover/20230713113902.56519-1-xingyu...@starfivetech.com/ V1: Changes since v1: - Further standardize the yaml file. - Dts naming convention improved. - Fix the problem of compiling and loading ko files. - Use drm new api to automatically manage resources. - Drop struct vs_crtc_funcs&vs_plane_funcs??subdivide the plane's help interface - Reduce the modifiers unused. - Optimize the hdmi driver code V2: Changes since v2: - fix the error about checking the yaml file. - match drm driver GEM DMA API. - Delete the custom crtc property . - hdmi use drmm_ new api to automatically manage resources. - update the modifiers comments. - enabling KASAN, fix the error during removing module Keith Zhao (6): dt-bindings: display: Add yamls for JH7110 display system riscv: dts: starfive: jh7110: add dc controller and hdmi node drm/fourcc: Add drm/vs tiled modifiers drm/vs: Register DRM device drm/vs: Add KMS crtc&plane drm/vs: Add hdmi driver .../starfive/starfive,display-subsystem.yaml | 41 + .../starfive/starfive,jh7110-dc8200.yaml | 109 + .../starfive/starfive,jh7110-inno-hdmi.yaml | 85 + MAINTAINERS |7 + .../jh7110-starfive-visionfive-2.dtsi | 91 + arch/riscv/boot/dts/starfive/jh7110.dtsi | 41 + drivers/gpu/drm/Kconfig |2 + drivers/gpu/drm/Makefile |1 + drivers/gpu/drm/verisilicon/Kconfig | 21 + drivers/gpu/drm/verisilicon/Makefile | 12 + drivers/gpu/drm/verisilicon/starfive_hdmi.c | 949 drivers/gpu/drm/verisilicon/starfive_hdmi.h | 295 +++ drivers/gpu/drm/verisilicon/vs_crtc.c | 257 +++ drivers/gpu/drm/verisilicon/vs_crtc.h | 43 + drivers/gpu/drm/verisilicon/vs_dc.c | 1002 + drivers/gpu/drm/verisilicon/vs_dc.h | 80 + drivers/gpu/drm/verisilicon/vs_dc_hw.c| 1959 + drivers/gpu/drm/verisilicon/vs_dc_hw.h| 492 + drivers/gpu/drm/verisilicon/vs_drv.c | 234 ++ drivers/gpu/drm/verisilicon/vs_drv.h | 31 + drivers/gpu/drm/verisilicon/vs_modeset.c | 36 + drivers/gpu/drm/verisilicon/vs_modeset.h | 10 + drivers/gpu/drm/verisilicon/vs_plane.c| 526 + drivers/gpu/drm/verisilicon/vs_plane.h| 58 + drivers/gpu/drm/verisilicon/vs_type.h | 69 + include/uapi/drm/drm_fourcc.h | 57 + include/uapi/drm/vs_drm.h | 50 + 27 files changed, 6558 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/starfive/starfive,display-subsystem.yaml create mode 100644 Documentation/devicetree/bindings/display/starfive/starfive,jh7110-dc8200.yaml create mode 100644 Documentation/devicetree/bindings/display/starfive/starfive,jh7110-inno-hdmi.yaml create mode 100644 drivers/gpu/drm/verisilicon/Kconfig create mode 100644 drivers/gpu/drm/verisilicon/Makefile create mode 100644 drivers/gpu/drm/verisilicon/starfive_hdmi.c create mode 100644 drivers/gpu/drm/verisilicon/starfive_hdmi.h create mode 100644 drivers/gpu/drm/verisilicon/vs_crtc.c create mode 100644 drivers/gpu/drm/verisilicon/vs_crtc.h create mode 100644 drivers/gpu/drm/verisilicon/vs_dc.c create mode 100644 drivers/gpu/drm/verisilicon/vs_dc.h create mode 100644 drivers/gpu/drm/verisilicon/vs_dc_hw.c create mode 100644 drivers/gpu/drm/verisilicon/vs_dc_hw.h create mode 100644 drivers/gpu/drm/verisilicon/vs_drv.c create mode 100644 drivers/gpu/drm/verisilicon/vs_drv.h create mode 100644 drivers/gpu/drm/verisilicon/vs_modeset.c create mode 100644 drivers/gpu/drm/verisilicon/vs_modeset.h create mode 100644 drivers/gpu/drm/verisilicon/vs_plane.c create mode 100644 drivers/gpu/drm/verisilicon/vs_plane.h create mode 100644 drivers/gpu/drm/verisilicon/vs_type.h create mode 100644 include/uapi/drm/vs_drm.h -- 2.34.1
[PATCH v2 3/6] drm/fourcc: Add drm/vs tiled modifiers
For each modifier, add the corresponding description Signed-off-by: Keith Zhao --- include/uapi/drm/drm_fourcc.h | 57 +++ 1 file changed, 57 insertions(+) diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h index 8db7fd3f7..a580a848c 100644 --- a/include/uapi/drm/drm_fourcc.h +++ b/include/uapi/drm/drm_fourcc.h @@ -419,6 +419,7 @@ extern "C" { #define DRM_FORMAT_MOD_VENDOR_ARM 0x08 #define DRM_FORMAT_MOD_VENDOR_ALLWINNER 0x09 #define DRM_FORMAT_MOD_VENDOR_AMLOGIC 0x0a +#define DRM_FORMAT_MOD_VENDOR_VERISILICON 0x0b /* add more to the end as needed */ @@ -1562,6 +1563,62 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier) #define AMD_FMT_MOD_CLEAR(field) \ (~((__u64)AMD_FMT_MOD_##field##_MASK << AMD_FMT_MOD_##field##_SHIFT)) +#define DRM_FORMAT_MOD_VERISILICON_TYPE_NORMAL 0x00 +#define DRM_FORMAT_MOD_VERISILICON_TYPE_MASK ((__u64)0x3 << 54) + +#define fourcc_mod_vs_code(type, val) \ + fourcc_mod_code(VERISILICON, __u64)type) << 54) | (val))) + +#define DRM_FORMAT_MOD_VERISILICON_NORM_MODE_MASK 0x1F + +/* + * An x-major 8x8 super tile consists of 64 8x8 sub-tiles in total. + * Each 8x8 sub-tile consists of four standard tiles . + * standard tiles (see Vivante 4x4 tiling layout) + */ +#define DRM_FORMAT_MOD_VERISILICON_SUPER_TILED_XMAJOR_8X8 0x02 + +/* + * A y-major 8x8 super tile consists of 64 8x8 sub-tiles in total. + * Each 8x8 sub-tile consists of four standard tiles . + * standard tiles (see Vivante 4x4 tiling layout) + */ +#define DRM_FORMAT_MOD_VERISILICON_SUPER_TILED_YMAJOR_8X8 0x03 + +/* + * An 8x8 tile consists of four standard tiles + * that are organized in Z-order. + * standard tiles (see Vivante 4x4 tiling layout) + */ +#define DRM_FORMAT_MOD_VERISILICON_TILE_8X8 0x04 + +/* + * An 8x4 tile consists of two standard tiles + * that are organized in Z-order. + * standard tiles (see Vivante 4x4 tiling layout) + */ +#define DRM_FORMAT_MOD_VERISILICON_TILE_8X4 0x07 + +/* + * An x-major 8x4 super tile consists of 128 8x4 sub-tiles in total. + * Each 8x4 sub-tile consists of two standard tiles. + * two standard tiles also same with DRM_FORMAT_MOD_VS_TILE_8X4 + * standard tiles (see Vivante 4x4 tiling layout) + */ +#define DRM_FORMAT_MOD_VERISILICON_SUPER_TILED_XMAJOR_8X4 0x0B + +/* + * A y-major 4x8 super tile consists of 128 4x8 sub-tiles in total. + * Each 4x8 sub-tile consists of two standard tiles. + * two standard tiles also same with DRM_FORMAT_MOD_VS_TILE_8X4 + * standard tiles (see Vivante 4x4 tiling layout) + */ +#define DRM_FORMAT_MOD_VERISILICON_SUPER_TILED_YMAJOR_4X80x0C + +#define fourcc_mod_vs_norm_code(tile) \ + fourcc_mod_vs_code(DRM_FORMAT_MOD_VERISILICON_TYPE_NORMAL, \ + (tile)) + #if defined(__cplusplus) } #endif -- 2.34.1
[PATCH v2 2/6] riscv: dts: starfive: jh7110: add dc controller and hdmi node
Add the dc controller and hdmi node for the Starfive JH7110 SoC. Signed-off-by: Keith Zhao --- .../jh7110-starfive-visionfive-2.dtsi | 91 +++ arch/riscv/boot/dts/starfive/jh7110.dtsi | 41 + 2 files changed, 132 insertions(+) diff --git a/arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-2.dtsi b/arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-2.dtsi index de0f40a8b..97909b6d2 100644 --- a/arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-2.dtsi +++ b/arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-2.dtsi @@ -31,6 +31,25 @@ memory@4000 { reg = <0x0 0x4000 0x1 0x0>; }; + reserved-memory { + #address-cells = <2>; + #size-cells = <2>; + ranges; + + /* vout applies for space from this CMA +* Without this CMA reservation, +* vout may not work properly. +*/ + linux,cma { + compatible = "shared-dma-pool"; + reusable; + size = <0x0 0x2000>; + alignment = <0x0 0x1000>; + alloc-ranges = <0x0 0x7000 0x0 0x2000>; + linux,cma-default; + }; + }; + gpio-restart { compatible = "gpio-restart"; gpios = <&sysgpio 35 GPIO_ACTIVE_HIGH>; @@ -231,6 +250,41 @@ GPOEN_DISABLE, slew-rate = <0>; }; }; + + hdmi_pins: hdmi-0 { + hdmi-scl-pins { + pinmux = ; + input-enable; + bias-pull-up; + }; + + hdmi-sda-pins { + pinmux = ; + input-enable; + bias-pull-up; + }; + + hdmi-cec-pins { + pinmux = ; + input-enable; + bias-pull-up; + }; + + hdmi-hpd-pins { + pinmux = ; + input-enable; + bias-disable; /* external pull-up */ + }; + }; + }; &uart0 { @@ -254,3 +308,40 @@ &U74_3 { &U74_4 { cpu-supply = <&vdd_cpu>; }; + +&voutcrg { + status = "okay"; +}; + +&display { + status = "okay"; +}; + +&hdmi { + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <&hdmi_pins>; + + hdmi_in: port { + #address-cells = <1>; + #size-cells = <0>; + hdmi_in_dc: endpoint@0 { + reg = <0>; + remote-endpoint = <&dc_out_hdmi>; + }; + }; +}; + +&dc8200 { + status = "okay"; + + dc_out: port { + #address-cells = <1>; + #size-cells = <0>; + dc_out_hdmi: endpoint@0 { + reg = <0>; + remote-endpoint = <&hdmi_in_dc>; + }; + + }; +}; diff --git a/arch/riscv/boot/dts/starfive/jh7110.dtsi b/arch/riscv/boot/dts/starfive/jh7110.dtsi index 0005fa163..1670452fb 100644 --- a/arch/riscv/boot/dts/starfive/jh7110.dtsi +++ b/arch/riscv/boot/dts/starfive/jh7110.dtsi @@ -282,6 +282,11 @@ tdm_ext: tdm-ext-clock { #clock-cells = <0>; }; + display: display-subsystem { + compatible = "starfive,display-subsystem"; + ports = <&dc_out>; + }; + soc { compatible = "simple-bus"; interrupt-parent = <&plic>; @@ -613,5 +618,41 @@ voutcrg: clock-controller@295c { #reset-cells = <1>; power-domains = <&pwrc JH7110_PD_VOUT>; }; + + dc8200: lcd-controller@2940 { + compatible = "starfive,jh7110-dc8200"; + reg = <0x0 0x2940 0x0 0x100>, + <0x0 0x29400800 0x0 0x2000>; + interrupts = <95>; + clocks = <&syscrg JH7110_SYSCLK_NOC_BUS_DISP_AXI>, + <&voutcrg JH7110_VOUTCLK_DC8200_PIX0>, + <&voutcrg JH7110_VOUTCLK_DC8200_PIX1>, + <&voutcrg JH7110_VOUTCLK_DC8200_CORE>, + <&voutcrg JH7110_VOUTCLK_DC8200_AXI>, + <&voutcrg JH7110_VOUTCLK_DC8200_AHB>, +
dri-devel@lists.freedesktop.org
hi Ville: very glad to receive your feedback Some of them are very good ideas. Some are not very clear and hope to get your further reply! On 2023/10/26 3:49, Ville Syrjälä wrote: > On Wed, Oct 25, 2023 at 10:28:56PM +0300, Dmitry Baryshkov wrote: >> On 25/10/2023 13:39, Keith Zhao wrote: >> > add 2 crtcs and 8 planes in vs-drm >> > >> > Signed-off-by: Keith Zhao >> > --- >> > drivers/gpu/drm/verisilicon/Makefile |8 +- >> > drivers/gpu/drm/verisilicon/vs_crtc.c | 257 >> > drivers/gpu/drm/verisilicon/vs_crtc.h | 43 + >> > drivers/gpu/drm/verisilicon/vs_dc.c| 1002 >> > drivers/gpu/drm/verisilicon/vs_dc.h| 80 + >> > drivers/gpu/drm/verisilicon/vs_dc_hw.c | 1959 >> > drivers/gpu/drm/verisilicon/vs_dc_hw.h | 492 ++ >> > drivers/gpu/drm/verisilicon/vs_drv.c |2 + >> > drivers/gpu/drm/verisilicon/vs_plane.c | 526 +++ >> > drivers/gpu/drm/verisilicon/vs_plane.h | 58 + >> > drivers/gpu/drm/verisilicon/vs_type.h | 69 + >> > 11 files changed, 4494 insertions(+), 2 deletions(-) >> > create mode 100644 drivers/gpu/drm/verisilicon/vs_crtc.c >> > create mode 100644 drivers/gpu/drm/verisilicon/vs_crtc.h >> > create mode 100644 drivers/gpu/drm/verisilicon/vs_dc.c >> > create mode 100644 drivers/gpu/drm/verisilicon/vs_dc.h >> > create mode 100644 drivers/gpu/drm/verisilicon/vs_dc_hw.c >> > create mode 100644 drivers/gpu/drm/verisilicon/vs_dc_hw.h >> > create mode 100644 drivers/gpu/drm/verisilicon/vs_plane.c >> > create mode 100644 drivers/gpu/drm/verisilicon/vs_plane.h >> > create mode 100644 drivers/gpu/drm/verisilicon/vs_type.h >> > >> > diff --git a/drivers/gpu/drm/verisilicon/Makefile >> > b/drivers/gpu/drm/verisilicon/Makefile >> > index 7d3be305b..1d48016ca 100644 >> > --- a/drivers/gpu/drm/verisilicon/Makefile >> > +++ b/drivers/gpu/drm/verisilicon/Makefile >> > @@ -1,7 +1,11 @@ >> > # SPDX-License-Identifier: GPL-2.0 >> > >> > -vs_drm-objs := vs_drv.o \ >> > - vs_modeset.o >> > +vs_drm-objs := vs_dc_hw.o \ >> > + vs_dc.o \ >> > + vs_crtc.o \ >> > + vs_drv.o \ >> > + vs_modeset.o \ >> > + vs_plane.o >> > >> > obj-$(CONFIG_DRM_VERISILICON) += vs_drm.o >> > >> > diff --git a/drivers/gpu/drm/verisilicon/vs_crtc.c >> > b/drivers/gpu/drm/verisilicon/vs_crtc.c >> > new file mode 100644 >> > index 0..8a658ea77 >> > --- /dev/null >> > +++ b/drivers/gpu/drm/verisilicon/vs_crtc.c >> > @@ -0,0 +1,257 @@ >> > +// SPDX-License-Identifier: GPL-2.0 >> > +/* >> > + * Copyright (C) 2023 VeriSilicon Holdings Co., Ltd. >> > + * >> > + */ >> > + >> > +#include >> > +#include >> > +#include >> > + >> > +#include >> > +#include >> > +#include >> > +#include >> > +#include >> > +#include >> > + >> > +#include "vs_crtc.h" >> > +#include "vs_dc.h" >> > +#include "vs_drv.h" >> > + >> > +static void vs_crtc_reset(struct drm_crtc *crtc) >> > +{ >> > + struct vs_crtc_state *state; >> > + >> > + if (crtc->state) { >> > + __drm_atomic_helper_crtc_destroy_state(crtc->state); >> > + >> > + state = to_vs_crtc_state(crtc->state); >> > + kfree(state); >> > + crtc->state = NULL; >> > + } >> >> You can call your crtc_destroy_state function directly here. ok got it ! >> >> > + >> > + state = kzalloc(sizeof(*state), GFP_KERNEL); >> > + if (!state) >> > + return; >> > + >> > + __drm_atomic_helper_crtc_reset(crtc, &state->base); >> > +} >> > + >> > +static struct drm_crtc_state * >> > +vs_crtc_atomic_duplicate_state(struct drm_crtc *crtc) >> > +{ >> > + struct vs_crtc_state *ori_state; >> >> It might be a matter of taste, but it is usually old_state. >> >> > + struct vs_crtc_state *state; >> > + >> > + if (!crtc->state) >> > + return NULL; >> > + >> > + ori_state = to_vs_crtc_state(crtc->state); >> > + state = kzalloc(sizeof(*state), GFP_KERNEL); >> > + if (
dri-devel@lists.freedesktop.org
sorry Dmitry ,accidentally wrote the wrong name Take no offense On 2023/10/26 17:42, Keith Zhao wrote: > hi Ville: > very glad to receive your feedback > Some of them are very good ideas. > Some are not very clear and hope to get your further reply! > > > On 2023/10/26 3:49, Ville Syrjälä wrote: >> On Wed, Oct 25, 2023 at 10:28:56PM +0300, Dmitry Baryshkov wrote: >>> On 25/10/2023 13:39, Keith Zhao wrote: >>> > add 2 crtcs and 8 planes in vs-drm >>> > >>> > Signed-off-by: Keith Zhao >>> > --- >>> > drivers/gpu/drm/verisilicon/Makefile |8 +- >>> > drivers/gpu/drm/verisilicon/vs_crtc.c | 257 >>> > drivers/gpu/drm/verisilicon/vs_crtc.h | 43 + >>> > drivers/gpu/drm/verisilicon/vs_dc.c| 1002 >>> > drivers/gpu/drm/verisilicon/vs_dc.h| 80 + >>> > drivers/gpu/drm/verisilicon/vs_dc_hw.c | 1959 >>> > drivers/gpu/drm/verisilicon/vs_dc_hw.h | 492 ++ >>> > drivers/gpu/drm/verisilicon/vs_drv.c |2 + >>> > drivers/gpu/drm/verisilicon/vs_plane.c | 526 +++ >>> > drivers/gpu/drm/verisilicon/vs_plane.h | 58 + >>> > drivers/gpu/drm/verisilicon/vs_type.h | 69 + >>> > 11 files changed, 4494 insertions(+), 2 deletions(-) >>> > create mode 100644 drivers/gpu/drm/verisilicon/vs_crtc.c >>> > create mode 100644 drivers/gpu/drm/verisilicon/vs_crtc.h >>> > create mode 100644 drivers/gpu/drm/verisilicon/vs_dc.c >>> > create mode 100644 drivers/gpu/drm/verisilicon/vs_dc.h >>> > create mode 100644 drivers/gpu/drm/verisilicon/vs_dc_hw.c >>> > create mode 100644 drivers/gpu/drm/verisilicon/vs_dc_hw.h >>> > create mode 100644 drivers/gpu/drm/verisilicon/vs_plane.c >>> > create mode 100644 drivers/gpu/drm/verisilicon/vs_plane.h >>> > create mode 100644 drivers/gpu/drm/verisilicon/vs_type.h >>> > >>> > diff --git a/drivers/gpu/drm/verisilicon/Makefile >>> > b/drivers/gpu/drm/verisilicon/Makefile >>> > index 7d3be305b..1d48016ca 100644 >>> > --- a/drivers/gpu/drm/verisilicon/Makefile >>> > +++ b/drivers/gpu/drm/verisilicon/Makefile >>> > @@ -1,7 +1,11 @@ >>> > # SPDX-License-Identifier: GPL-2.0 >>> > >>> > -vs_drm-objs := vs_drv.o \ >>> > - vs_modeset.o >>> > +vs_drm-objs := vs_dc_hw.o \ >>> > + vs_dc.o \ >>> > + vs_crtc.o \ >>> > + vs_drv.o \ >>> > + vs_modeset.o \ >>> > + vs_plane.o >>> > >>> > obj-$(CONFIG_DRM_VERISILICON) += vs_drm.o >>> > >>> > diff --git a/drivers/gpu/drm/verisilicon/vs_crtc.c >>> > b/drivers/gpu/drm/verisilicon/vs_crtc.c >>> > new file mode 100644 >>> > index 0..8a658ea77 >>> > --- /dev/null >>> > +++ b/drivers/gpu/drm/verisilicon/vs_crtc.c >>> > @@ -0,0 +1,257 @@ >>> > +// SPDX-License-Identifier: GPL-2.0 >>> > +/* >>> > + * Copyright (C) 2023 VeriSilicon Holdings Co., Ltd. >>> > + * >>> > + */ >>> > + >>> > +#include >>> > +#include >>> > +#include >>> > + >>> > +#include >>> > +#include >>> > +#include >>> > +#include >>> > +#include >>> > +#include >>> > + >>> > +#include "vs_crtc.h" >>> > +#include "vs_dc.h" >>> > +#include "vs_drv.h" >>> > + >>> > +static void vs_crtc_reset(struct drm_crtc *crtc) >>> > +{ >>> > + struct vs_crtc_state *state; >>> > + >>> > + if (crtc->state) { >>> > + __drm_atomic_helper_crtc_destroy_state(crtc->state); >>> > + >>> > + state = to_vs_crtc_state(crtc->state); >>> > + kfree(state); >>> > + crtc->state = NULL; >>> > + } >>> >>> You can call your crtc_destroy_state function directly here. > ok got it ! >>> >>> > + >>> > + state = kzalloc(sizeof(*state), GFP_KERNEL); >>> > + if (!state) >>> > + return; >>> > + >>> > + __drm_atomic_helper_crtc_reset(crtc, &state->base); >>> > +} >>> > + >>> > +static struct drm_crtc_state * >
Re: [PATCH v2 6/6] drm/vs: Add hdmi driver
On 2023/10/26 6:23, Dmitry Baryshkov wrote: > On 25/10/2023 13:39, Keith Zhao wrote: >> add hdmi driver as encoder and connect >> >> Signed-off-by: Keith Zhao >> --- >> drivers/gpu/drm/verisilicon/Kconfig | 8 +- >> drivers/gpu/drm/verisilicon/Makefile | 1 + >> drivers/gpu/drm/verisilicon/starfive_hdmi.c | 949 >> drivers/gpu/drm/verisilicon/starfive_hdmi.h | 295 ++ >> drivers/gpu/drm/verisilicon/vs_drv.c | 5 + >> drivers/gpu/drm/verisilicon/vs_drv.h | 4 + >> 6 files changed, 1261 insertions(+), 1 deletion(-) >> create mode 100644 drivers/gpu/drm/verisilicon/starfive_hdmi.c >> create mode 100644 drivers/gpu/drm/verisilicon/starfive_hdmi.h >> >> diff --git a/drivers/gpu/drm/verisilicon/Kconfig >> b/drivers/gpu/drm/verisilicon/Kconfig >> index 3a361f8c8..122c786e3 100644 >> --- a/drivers/gpu/drm/verisilicon/Kconfig >> +++ b/drivers/gpu/drm/verisilicon/Kconfig >> @@ -12,4 +12,10 @@ config DRM_VERISILICON >> setting and buffer management. It does not >> provide 2D or 3D acceleration. >> - >> +config DRM_VERISILICON_STARFIVE_HDMI >> + bool "Starfive HDMI extensions" >> + depends on DRM_VERISILICON >> + help >> + This selects support for StarFive soc specific extensions >> + for the Innosilicon HDMI driver. If you want to enable >> + HDMI on JH7110 based soc, you should select this option. >> diff --git a/drivers/gpu/drm/verisilicon/Makefile >> b/drivers/gpu/drm/verisilicon/Makefile >> index 1d48016ca..08350f25b 100644 >> --- a/drivers/gpu/drm/verisilicon/Makefile >> +++ b/drivers/gpu/drm/verisilicon/Makefile >> @@ -7,5 +7,6 @@ vs_drm-objs := vs_dc_hw.o \ >> vs_modeset.o \ >> vs_plane.o >> +vs_drm-$(CONFIG_DRM_VERISILICON_STARFIVE_HDMI) += starfive_hdmi.o >> obj-$(CONFIG_DRM_VERISILICON) += vs_drm.o >> diff --git a/drivers/gpu/drm/verisilicon/starfive_hdmi.c >> b/drivers/gpu/drm/verisilicon/starfive_hdmi.c >> new file mode 100644 >> index 0..d296c4b71 >> --- /dev/null >> +++ b/drivers/gpu/drm/verisilicon/starfive_hdmi.c >> @@ -0,0 +1,949 @@ >> +// SPDX-License-Identifier: GPL-2.0-only >> +/* >> + * Copyright (C) 2023 StarFive Technology Co., Ltd. >> + */ >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +#include "starfive_hdmi.h" >> +#include "vs_drv.h" >> +#include "vs_crtc.h" >> + >> +static struct starfive_hdmi *encoder_to_hdmi(struct drm_encoder *encoder) >> +{ >> + return container_of(encoder, struct starfive_hdmi, encoder); >> +} >> + >> +static struct starfive_hdmi *connector_to_hdmi(struct drm_connector >> *connector) >> +{ >> + return container_of(connector, struct starfive_hdmi, connector); >> +} >> + >> +struct starfive_hdmi_i2c { >> + struct i2c_adapter adap; >> + >> + u8 ddc_addr; >> + u8 segment_addr; >> + /* protects the edid data when use i2c cmd to read edid */ >> + struct mutex lock; >> + struct completion cmp; >> +}; >> + >> +static const struct pre_pll_config pre_pll_cfg_table[] = { >> + { 25175000, 25175000, 1, 100, 2, 3, 3, 12, 3, 3, 4, 0, 0xf5}, >> + { 2520, 2520, 1, 100, 2, 3, 3, 12, 3, 3, 4, 0, 0}, >> + { 2700, 2700, 1, 90, 3, 2, 2, 10, 3, 3, 4, 0, 0}, > > Such data structures are usually pretyt limited and hard to handle. Could you > please replace it with the runtime calculations of > >> + { 27027000, 27027000, 1, 90, 3, 2, 2, 10, 3, 3, 4, 0, 0x170a3d}, >> + { 2832, 2832, 1, 28, 2, 1, 1, 3, 0, 3, 4, 0, 0x51eb85}, >> + { 3024, 3024, 1, 30, 2, 1, 1, 3, 0, 3, 4, 0, 0x3d70a3}, >> + { 3150, 3150, 1, 31, 2, 1, 1, 3, 0, 3, 4, 0, 0x7f}, >> + { 3375, 3375, 1, 33, 2, 1, 1, 3, 0, 3, 4, 0, 0xcf}, >> + { 3600, 3600, 1, 36, 2, 1, 1, 3, 0, 3, 4, 0, 0}, >> + { 4000, 4000, 1, 80, 2, 2, 2, 12, 2, 2, 2, 0, 0}, >> + { 4697, 4697, 1, 46, 2, 1, 1, 3, 0, 3, 4, 0, 0xf851eb}, >> + { 4950, 49500
Re: [PATCH v2 6/6] drm/vs: Add hdmi driver
On 2023/11/13 21:31, Dmitry Baryshkov wrote: > On Mon, 13 Nov 2023 at 14:11, Keith Zhao wrote: >> >> >> >> On 2023/10/26 6:23, Dmitry Baryshkov wrote: >> > On 25/10/2023 13:39, Keith Zhao wrote: >> >> add hdmi driver as encoder and connect >> >> >> >> Signed-off-by: Keith Zhao >> >> --- >> >> drivers/gpu/drm/verisilicon/Kconfig | 8 +- >> >> drivers/gpu/drm/verisilicon/Makefile| 1 + >> >> drivers/gpu/drm/verisilicon/starfive_hdmi.c | 949 >> >> drivers/gpu/drm/verisilicon/starfive_hdmi.h | 295 ++ >> >> drivers/gpu/drm/verisilicon/vs_drv.c| 5 + >> >> drivers/gpu/drm/verisilicon/vs_drv.h| 4 + >> >> 6 files changed, 1261 insertions(+), 1 deletion(-) >> >> create mode 100644 drivers/gpu/drm/verisilicon/starfive_hdmi.c >> >> create mode 100644 drivers/gpu/drm/verisilicon/starfive_hdmi.h >> >> >> >> diff --git a/drivers/gpu/drm/verisilicon/Kconfig >> >> b/drivers/gpu/drm/verisilicon/Kconfig >> >> index 3a361f8c8..122c786e3 100644 >> >> --- a/drivers/gpu/drm/verisilicon/Kconfig >> >> +++ b/drivers/gpu/drm/verisilicon/Kconfig >> >> @@ -12,4 +12,10 @@ config DRM_VERISILICON >> >> setting and buffer management. It does not >> >> provide 2D or 3D acceleration. >> >> - >> >> +config DRM_VERISILICON_STARFIVE_HDMI >> >> +bool "Starfive HDMI extensions" >> >> +depends on DRM_VERISILICON >> >> +help >> >> + This selects support for StarFive soc specific extensions >> >> + for the Innosilicon HDMI driver. If you want to enable >> >> + HDMI on JH7110 based soc, you should select this option. >> >> diff --git a/drivers/gpu/drm/verisilicon/Makefile >> >> b/drivers/gpu/drm/verisilicon/Makefile >> >> index 1d48016ca..08350f25b 100644 >> >> --- a/drivers/gpu/drm/verisilicon/Makefile >> >> +++ b/drivers/gpu/drm/verisilicon/Makefile >> >> @@ -7,5 +7,6 @@ vs_drm-objs := vs_dc_hw.o \ >> >> vs_modeset.o \ >> >> vs_plane.o >> >> +vs_drm-$(CONFIG_DRM_VERISILICON_STARFIVE_HDMI) += starfive_hdmi.o >> >> obj-$(CONFIG_DRM_VERISILICON) += vs_drm.o >> >> diff --git a/drivers/gpu/drm/verisilicon/starfive_hdmi.c >> >> b/drivers/gpu/drm/verisilicon/starfive_hdmi.c >> >> new file mode 100644 >> >> index 0..d296c4b71 >> >> --- /dev/null >> >> +++ b/drivers/gpu/drm/verisilicon/starfive_hdmi.c >> >> @@ -0,0 +1,949 @@ >> >> +// SPDX-License-Identifier: GPL-2.0-only >> >> +/* >> >> + * Copyright (C) 2023 StarFive Technology Co., Ltd. >> >> + */ >> >> + >> >> +#include >> >> +#include >> >> +#include >> >> +#include >> >> +#include >> >> +#include >> >> +#include >> >> +#include >> >> +#include >> >> +#include >> >> +#include >> >> +#include >> >> +#include >> >> +#include >> >> + >> >> +#include >> >> +#include >> >> +#include >> >> +#include >> >> +#include >> >> +#include >> >> +#include >> >> + >> >> +#include "starfive_hdmi.h" >> >> +#include "vs_drv.h" >> >> +#include "vs_crtc.h" >> >> + >> >> +static struct starfive_hdmi *encoder_to_hdmi(struct drm_encoder *encoder) >> >> +{ >> >> +return container_of(encoder, struct starfive_hdmi, encoder); >> >> +} >> >> + >> >> +static struct starfive_hdmi *connector_to_hdmi(struct drm_connector >> >> *connector) >> >> +{ >> >> +return container_of(connector, struct starfive_hdmi, connector); >> >> +} >> >> + >> >> +struct starfive_hdmi_i2c { >> >> +struct i2c_adapter adap; >> >> + >> >> +u8 ddc_addr; >> >> +u8 segment_addr; >> >> +/* protects the edid data when use i2c cmd to read edid */ >> >> +struct mutex lock; >> >> +struct completion cmp; >> >> +}; >> >> + >> >> +static const struct pre_pll_config pre_pl
dri-devel@lists.freedesktop.org
On 2023/10/26 3:28, Dmitry Baryshkov wrote: > On 25/10/2023 13:39, Keith Zhao wrote: >> add 2 crtcs and 8 planes in vs-drm >> >> Signed-off-by: Keith Zhao >> --- >> drivers/gpu/drm/verisilicon/Makefile |8 +- >> drivers/gpu/drm/verisilicon/vs_crtc.c | 257 >> drivers/gpu/drm/verisilicon/vs_crtc.h | 43 + >> drivers/gpu/drm/verisilicon/vs_dc.c| 1002 >> drivers/gpu/drm/verisilicon/vs_dc.h| 80 + >> drivers/gpu/drm/verisilicon/vs_dc_hw.c | 1959 >> drivers/gpu/drm/verisilicon/vs_dc_hw.h | 492 ++ >> drivers/gpu/drm/verisilicon/vs_drv.c |2 + >> drivers/gpu/drm/verisilicon/vs_plane.c | 526 +++ >> drivers/gpu/drm/verisilicon/vs_plane.h | 58 + >> drivers/gpu/drm/verisilicon/vs_type.h | 69 + >> 11 files changed, 4494 insertions(+), 2 deletions(-) >> create mode 100644 drivers/gpu/drm/verisilicon/vs_crtc.c >> create mode 100644 drivers/gpu/drm/verisilicon/vs_crtc.h >> create mode 100644 drivers/gpu/drm/verisilicon/vs_dc.c >> create mode 100644 drivers/gpu/drm/verisilicon/vs_dc.h >> create mode 100644 drivers/gpu/drm/verisilicon/vs_dc_hw.c >> create mode 100644 drivers/gpu/drm/verisilicon/vs_dc_hw.h >> create mode 100644 drivers/gpu/drm/verisilicon/vs_plane.c >> create mode 100644 drivers/gpu/drm/verisilicon/vs_plane.h >> create mode 100644 drivers/gpu/drm/verisilicon/vs_type.h >> >> diff --git a/drivers/gpu/drm/verisilicon/Makefile >> b/drivers/gpu/drm/verisilicon/Makefile >> index 7d3be305b..1d48016ca 100644 >> --- a/drivers/gpu/drm/verisilicon/Makefile >> +++ b/drivers/gpu/drm/verisilicon/Makefile >> @@ -1,7 +1,11 @@ >> # SPDX-License-Identifier: GPL-2.0 >> >> -vs_drm-objs := vs_drv.o \ >> -vs_modeset.o >> +vs_drm-objs := vs_dc_hw.o \ >> +vs_dc.o \ >> +vs_crtc.o \ >> +vs_drv.o \ >> +vs_modeset.o \ >> +vs_plane.o >> >> obj-$(CONFIG_DRM_VERISILICON) += vs_drm.o >> >> diff --git a/drivers/gpu/drm/verisilicon/vs_crtc.c >> b/drivers/gpu/drm/verisilicon/vs_crtc.c >> new file mode 100644 >> index 0..8a658ea77 >> --- /dev/null >> +++ b/drivers/gpu/drm/verisilicon/vs_crtc.c >> @@ -0,0 +1,257 @@ >> +// SPDX-License-Identifier: GPL-2.0 >> +/* >> + * Copyright (C) 2023 VeriSilicon Holdings Co., Ltd. >> + * >> + */ >> + >> +#include >> +#include >> +#include >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +#include "vs_crtc.h" >> +#include "vs_dc.h" >> +#include "vs_drv.h" >> + >> +static void vs_crtc_reset(struct drm_crtc *crtc) >> +{ >> +struct vs_crtc_state *state; >> + >> +if (crtc->state) { >> +__drm_atomic_helper_crtc_destroy_state(crtc->state); >> + >> +state = to_vs_crtc_state(crtc->state); >> +kfree(state); >> +crtc->state = NULL; >> +} > > You can call your crtc_destroy_state function directly here. > >> + >> +state = kzalloc(sizeof(*state), GFP_KERNEL); >> +if (!state) >> +return; >> + >> +__drm_atomic_helper_crtc_reset(crtc, &state->base); >> +} >> + >> +static struct drm_crtc_state * >> +vs_crtc_atomic_duplicate_state(struct drm_crtc *crtc) >> +{ >> +struct vs_crtc_state *ori_state; > > It might be a matter of taste, but it is usually old_state. > >> +struct vs_crtc_state *state; >> + >> +if (!crtc->state) >> +return NULL; >> + >> +ori_state = to_vs_crtc_state(crtc->state); >> +state = kzalloc(sizeof(*state), GFP_KERNEL); >> +if (!state) >> +return NULL; >> + >> +__drm_atomic_helper_crtc_duplicate_state(crtc, &state->base); >> + >> +state->output_fmt = ori_state->output_fmt; >> +state->encoder_type = ori_state->encoder_type; >> +state->bpp = ori_state->bpp; >> +state->underflow = ori_state->underflow; > > Can you use kmemdup instead? > >> + >> +return &state->base; >> +} >> + >> +static void vs_crtc_atomic_destroy_state(struct drm_crtc *crtc, >> + struct drm_crtc_state *state) >> +{ >> +__drm_atomic_helper_crtc_destr
Re: [PATCH v2 3/6] drm/fourcc: Add drm/vs tiled modifiers
ok, I will do this in my next patch Thanks your advice! On 2023/10/25 23:44, Simon Ser wrote: > it seems like you could start with just simple > enumerated modifiers like Intel does, and then only switch to more > complicated logic with macros and fields if there is an actual need in > the future.
dri-devel@lists.freedesktop.org
On 2023/10/25 21:57, Maxime Ripard wrote: > On Wed, Oct 25, 2023 at 06:39:56PM +0800, Keith Zhao wrote: >> +static struct drm_crtc_state * >> +vs_crtc_atomic_duplicate_state(struct drm_crtc *crtc) >> +{ >> +struct vs_crtc_state *ori_state; >> +struct vs_crtc_state *state; >> + >> +if (!crtc->state) >> +return NULL; >> + >> +ori_state = to_vs_crtc_state(crtc->state); >> +state = kzalloc(sizeof(*state), GFP_KERNEL); >> +if (!state) >> +return NULL; >> + >> +__drm_atomic_helper_crtc_duplicate_state(crtc, &state->base); >> + >> +state->output_fmt = ori_state->output_fmt; > > That field is never set in your patch. > >> +state->encoder_type = ori_state->encoder_type; > > That isn't either, and it's not clear why you would need the > encoder_type stored in the CRTC? > >> +state->bpp = ori_state->bpp; > > You seem to derive that from output_fmt, it doesn't need to be in the > CRTC state. > >> +state->underflow = ori_state->underflow; > > Assuming you're setting this from the interrupt handler, it's unsafe, > you shouldn't do that. What are you using it for? I am going to use the crtc_debugfs function for printing. crtc_debugfs will use it But now I'd better delete it > >> +static const struct drm_prop_enum_list vs_sync_mode_enum_list[] = { >> +{ VS_SINGLE_DC, "single dc mode" }, >> +{ VS_MULTI_DC_PRIMARY, "primary dc for multi dc mode" }, >> +{ VS_MULTI_DC_SECONDARY,"secondary dc for multi dc mode" }, >> +}; > > Custom driver properties are a no-go: > https://docs.kernel.org/gpu/drm-kms.html#requirements > > And > > https://docs.kernel.org/gpu/drm-uapi.html#open-source-userspace-requirements > >> +void vs_dc_enable(struct vs_dc *dc, struct drm_crtc *crtc) >> +{ >> +struct vs_crtc_state *crtc_state = to_vs_crtc_state(crtc->state); >> +struct drm_display_mode *mode = &crtc->state->adjusted_mode; >> +struct dc_hw_display display; > > Why are you rolling your own structure here, if it's exactly equivalent > to what drm_display_mode and the crtc_state provide? My original intention was to make the hardware part purer. and want to decouple hardware from drm struct. so I define the own structure between drm and hardware. Maybe doing this will make both the hardware and drm happy > >> +void vs_dc_commit(struct vs_dc *dc) >> +{ >> +dc_hw_enable_shadow_register(&dc->hw, false); >> + >> +dc_hw_commit(&dc->hw); >> + >> +if (dc->first_frame) >> +dc->first_frame = false; >> + >> +dc_hw_enable_shadow_register(&dc->hw, true); >> +} > > It's not clear to me what you're trying to do here, does the hardware > have latched registers that are only updated during vblank? > >> +static int dc_bind(struct device *dev, struct device *master, void *data) >> +{ >> +struct drm_device *drm_dev = data; >> +struct vs_dc *dc = dev_get_drvdata(dev); >> +struct device_node *port; >> +struct vs_crtc *crtc; >> +struct vs_dc_info *dc_info; >> +struct vs_plane *plane; >> +struct vs_plane_info *plane_info; >> +int i, ret; >> +u32 ctrc_mask = 0; >> + >> +if (!drm_dev || !dc) { >> +dev_err(dev, "devices are not created.\n"); >> +return -ENODEV; >> +} >> + >> +ret = dc_init(dev); >> +if (ret < 0) { >> +drm_err(drm_dev, "Failed to initialize DC hardware.\n"); >> +return ret; >> +} >> + >> +port = of_get_child_by_name(dev->of_node, "port"); >> +if (!port) { >> +drm_err(drm_dev, "no port node found\n"); >> +return -ENODEV; >> +} >> +of_node_put(port); >> + >> +dc_info = dc->hw.info; >> + >> +for (i = 0; i < dc_info->panel_num; i++) { >> +crtc = vs_crtc_create(drm_dev, dc_info); >> +if (!crtc) { >> +drm_err(drm_dev, "Failed to create CRTC.\n"); >> +ret = -ENOMEM; >> +return ret; >> +} >> + >> +crtc->base.port = port; >> +crtc->dev = dev; >> +dc-&g
dri-devel@lists.freedesktop.org
> -邮件原件- > 发件人: Maxime Ripard > 发送时间: 2023年12月6日 16:56 > 收件人: Keith Zhao > 抄送: devicet...@vger.kernel.org; dri-devel@lists.freedesktop.org; > linux-ker...@vger.kernel.org; linux-ri...@lists.infradead.org; > tzimmerm...@suse.de; airl...@gmail.com; krzysztof.kozlowski...@linaro.org; > William Qiu ; Xingyu Wu > ; paul.walms...@sifive.com; > a...@eecs.berkeley.edu; pal...@dabbelt.com; p.za...@pengutronix.de; > Shengyang Chen ; Jack Zhu > ; Changhuang Liang > ; maarten.lankho...@linux.intel.com; > suijingf...@loongson.cn > 主题: Re: [v3 4/6] drm/vs: Add KMS crtc&plane > > On Mon, Dec 04, 2023 at 08:33:13PM +0800, Keith Zhao wrote: > > +static const struct vs_plane_info dc_hw_planes_rev0[PLANE_NUM] = { > > + { > > + .name = "Primary", > > + .id = PRIMARY_PLANE_0, > > + .type = DRM_PLANE_TYPE_PRIMARY, > > + .num_formats= ARRAY_SIZE(primary_overlay_format0), > > + .formats= primary_overlay_format0, > > + .num_modifiers = ARRAY_SIZE(format_modifier0), > > + .modifiers = format_modifier0, > > + .min_width = 0, > > + .min_height = 0, > > + .max_width = 4096, > > + .max_height = 4096, > > + .rotation = DRM_MODE_ROTATE_0 | > > + DRM_MODE_ROTATE_90 | > > + DRM_MODE_ROTATE_180 | > > + DRM_MODE_ROTATE_270 | > > + DRM_MODE_REFLECT_X | > > + DRM_MODE_REFLECT_Y, > > + .blend_mode = BIT(DRM_MODE_BLEND_PIXEL_NONE) | > > + BIT(DRM_MODE_BLEND_PREMULTI) | > > + BIT(DRM_MODE_BLEND_COVERAGE), > > + .color_encoding = BIT(DRM_COLOR_YCBCR_BT709) | > > + BIT(DRM_COLOR_YCBCR_BT2020), > > + .degamma_size = DEGAMMA_SIZE, > > + .min_scale = FRAC_16_16(1, 3), > > + .max_scale = FRAC_16_16(10, 1), > > + .zpos = 0, > > + .watermark = true, > > + .color_mgmt = true, > > + .roi= true, > > + }, > > + { > > + .name = "Overlay", > > + .id = OVERLAY_PLANE_0, > > + .type = DRM_PLANE_TYPE_OVERLAY, > > + .num_formats= ARRAY_SIZE(primary_overlay_format0), > > + .formats= primary_overlay_format0, > > + .num_modifiers = ARRAY_SIZE(format_modifier0), > > + .modifiers = format_modifier0, > > + .min_width = 0, > > + .min_height = 0, > > + .max_width = 4096, > > + .max_height = 4096, > > + .rotation = DRM_MODE_ROTATE_0 | > > + DRM_MODE_ROTATE_90 | > > + DRM_MODE_ROTATE_180 | > > + DRM_MODE_ROTATE_270 | > > + DRM_MODE_REFLECT_X | > > + DRM_MODE_REFLECT_Y, > > + .blend_mode = BIT(DRM_MODE_BLEND_PIXEL_NONE) | > > + BIT(DRM_MODE_BLEND_PREMULTI) | > > + BIT(DRM_MODE_BLEND_COVERAGE), > > + .color_encoding = BIT(DRM_COLOR_YCBCR_BT709) | > > + BIT(DRM_COLOR_YCBCR_BT2020), > > + .degamma_size = DEGAMMA_SIZE, > > + .min_scale = FRAC_16_16(1, 3), > > + .max_scale = FRAC_16_16(10, 1), > > + .zpos = 1, > > + .watermark = true, > > + .color_mgmt = true, > > + .roi= true, > > + }, > > + { > > + .name = "Overlay_1", > > + .id = OVERLAY_PLANE_1, > > + .type = DRM_PLANE_TYPE_OVERLAY, > > + .num_formats
dri-devel@lists.freedesktop.org
> -邮件原件- > 发件人: Maxime Ripard > 发送时间: 2023年12月6日 16:56 > 收件人: Keith Zhao > 抄送: devicet...@vger.kernel.org; dri-devel@lists.freedesktop.org; > linux-ker...@vger.kernel.org; linux-ri...@lists.infradead.org; > tzimmerm...@suse.de; airl...@gmail.com; krzysztof.kozlowski...@linaro.org; > William Qiu ; Xingyu Wu > ; paul.walms...@sifive.com; > a...@eecs.berkeley.edu; pal...@dabbelt.com; p.za...@pengutronix.de; > Shengyang Chen ; Jack Zhu > ; Changhuang Liang > ; maarten.lankho...@linux.intel.com; > suijingf...@loongson.cn > 主题: Re: [v3 4/6] drm/vs: Add KMS crtc&plane > > On Mon, Dec 04, 2023 at 08:33:13PM +0800, Keith Zhao wrote: > > +static const struct vs_plane_info dc_hw_planes_rev0[PLANE_NUM] = { > > + { > > + .name = "Primary", > > + .id = PRIMARY_PLANE_0, > > + .type = DRM_PLANE_TYPE_PRIMARY, > > + .num_formats= ARRAY_SIZE(primary_overlay_format0), > > + .formats= primary_overlay_format0, > > + .num_modifiers = ARRAY_SIZE(format_modifier0), > > + .modifiers = format_modifier0, > > + .min_width = 0, > > + .min_height = 0, > > + .max_width = 4096, > > + .max_height = 4096, > > + .rotation = DRM_MODE_ROTATE_0 | > > + DRM_MODE_ROTATE_90 | > > + DRM_MODE_ROTATE_180 | > > + DRM_MODE_ROTATE_270 | > > + DRM_MODE_REFLECT_X | > > + DRM_MODE_REFLECT_Y, > > + .blend_mode = BIT(DRM_MODE_BLEND_PIXEL_NONE) | > > + BIT(DRM_MODE_BLEND_PREMULTI) | > > + BIT(DRM_MODE_BLEND_COVERAGE), > > + .color_encoding = BIT(DRM_COLOR_YCBCR_BT709) | > > + BIT(DRM_COLOR_YCBCR_BT2020), > > + .degamma_size = DEGAMMA_SIZE, > > + .min_scale = FRAC_16_16(1, 3), > > + .max_scale = FRAC_16_16(10, 1), > > + .zpos = 0, > > + .watermark = true, > > + .color_mgmt = true, > > + .roi= true, > > + }, > > + { > > + .name = "Overlay", > > + .id = OVERLAY_PLANE_0, > > + .type = DRM_PLANE_TYPE_OVERLAY, > > + .num_formats= ARRAY_SIZE(primary_overlay_format0), > > + .formats= primary_overlay_format0, > > + .num_modifiers = ARRAY_SIZE(format_modifier0), > > + .modifiers = format_modifier0, > > + .min_width = 0, > > + .min_height = 0, > > + .max_width = 4096, > > + .max_height = 4096, > > + .rotation = DRM_MODE_ROTATE_0 | > > + DRM_MODE_ROTATE_90 | > > + DRM_MODE_ROTATE_180 | > > + DRM_MODE_ROTATE_270 | > > + DRM_MODE_REFLECT_X | > > + DRM_MODE_REFLECT_Y, > > + .blend_mode = BIT(DRM_MODE_BLEND_PIXEL_NONE) | > > + BIT(DRM_MODE_BLEND_PREMULTI) | > > + BIT(DRM_MODE_BLEND_COVERAGE), > > + .color_encoding = BIT(DRM_COLOR_YCBCR_BT709) | > > + BIT(DRM_COLOR_YCBCR_BT2020), > > + .degamma_size = DEGAMMA_SIZE, > > + .min_scale = FRAC_16_16(1, 3), > > + .max_scale = FRAC_16_16(10, 1), > > + .zpos = 1, > > + .watermark = true, > > + .color_mgmt = true, > > + .roi= true, > > + }, > > + { > > + .name = "Overlay_1", > > + .id = OVERLAY_PLANE_1, > > + .type = DRM_PLANE_TYPE_OVERLAY, > > + .num_formats
RE: [v3 6/6] drm/vs: simple encoder
> -Original Message- > From: Dmitry Baryshkov > Sent: 2023年12月5日 21:19 > To: Keith Zhao > Cc: devicet...@vger.kernel.org; dri-devel@lists.freedesktop.org; > linux-ker...@vger.kernel.org; linux-ri...@lists.infradead.org; > a...@eecs.berkeley.edu; suijingf...@loongson.cn; tzimmerm...@suse.de; > paul.walms...@sifive.com; mrip...@kernel.org; Xingyu Wu > ; Jack Zhu ; > pal...@dabbelt.com; krzysztof.kozlowski...@linaro.org; William Qiu > ; Shengyang Chen > ; Changhuang Liang > > Subject: Re: [v3 6/6] drm/vs: simple encoder > > On Tue, 5 Dec 2023 at 15:14, Dmitry Baryshkov > wrote: > > > > On Mon, 4 Dec 2023 at 14:33, Keith Zhao > wrote: > > > > > > add simple encoder for dsi bridge > > > > This doesn't look like a proper commit message. > > > > > > > > Signed-off-by: Keith Zhao > > > --- > > > drivers/gpu/drm/verisilicon/Makefile| 4 +- > > > drivers/gpu/drm/verisilicon/vs_drv.c| 2 + > > > drivers/gpu/drm/verisilicon/vs_simple_enc.c | 195 > > > drivers/gpu/drm/verisilicon/vs_simple_enc.h | > > > 23 +++ > > > 4 files changed, 223 insertions(+), 1 deletion(-) create mode > > > 100644 drivers/gpu/drm/verisilicon/vs_simple_enc.c > > > create mode 100644 drivers/gpu/drm/verisilicon/vs_simple_enc.h > > > > > > diff --git a/drivers/gpu/drm/verisilicon/Makefile > > > b/drivers/gpu/drm/verisilicon/Makefile > > > index 71fadafcee13..cd5d0a90bcfe 100644 > > > --- a/drivers/gpu/drm/verisilicon/Makefile > > > +++ b/drivers/gpu/drm/verisilicon/Makefile > > > @@ -5,6 +5,8 @@ vs_drm-objs := vs_dc_hw.o \ > > > vs_crtc.o \ > > > vs_drv.o \ > > > vs_modeset.o \ > > > - vs_plane.o > > > + vs_plane.o \ > > > + vs_simple_enc.o > > > + > > > vs_drm-$(CONFIG_DRM_VERISILICON_STARFIVE_HDMI) += > starfive_hdmi.o > > > obj-$(CONFIG_DRM_VERISILICON) += vs_drm.o diff --git > > > a/drivers/gpu/drm/verisilicon/vs_drv.c > > > b/drivers/gpu/drm/verisilicon/vs_drv.c > > > index d7e5199fe293..946f137ab124 100644 > > > --- a/drivers/gpu/drm/verisilicon/vs_drv.c > > > +++ b/drivers/gpu/drm/verisilicon/vs_drv.c > > > @@ -23,6 +23,7 @@ > > > #include "vs_drv.h" > > > #include "vs_modeset.h" > > > #include "vs_dc.h" > > > +#include "vs_simple_enc.h" > > > > > > #define DRV_NAME "verisilicon" > > > #define DRV_DESC "Verisilicon DRM driver" > > > @@ -217,6 +218,7 @@ static struct platform_driver *drm_sub_drivers[] > > > = { #ifdef CONFIG_DRM_VERISILICON_STARFIVE_HDMI > > > &starfive_hdmi_driver, > > > #endif > > > + &simple_encoder_driver, > > > }; > > > > > > static struct component_match *vs_drm_match_add(struct device *dev) > > > diff --git a/drivers/gpu/drm/verisilicon/vs_simple_enc.c > > > b/drivers/gpu/drm/verisilicon/vs_simple_enc.c > > > new file mode 100644 > > > index ..c5a8d82bc469 > > > --- /dev/null > > > +++ b/drivers/gpu/drm/verisilicon/vs_simple_enc.c > > > @@ -0,0 +1,195 @@ > > > +// SPDX-License-Identifier: GPL-2.0 > > > +/* > > > + * Copyright (C) 2020 VeriSilicon Holdings Co., Ltd. > > > + */ > > > +#include > > > +#include > > > +#include > > > + > > > +#include > > > +#include > > > +#include > > > +#include > > > +#include > > > +#include #include > > > + > > > +#include "vs_crtc.h" > > > +#include "vs_simple_enc.h" > > > + > > > +static const struct simple_encoder_priv dsi_priv = { > > > > Please use proper prefix for all the struct and function names. > > vs_simple_encoder sounds better. Or vs_dsi_encoder. > > > > > + .encoder_type = DRM_MODE_ENCODER_DSI }; > > > + > > > +static inline struct simple_encoder *to_simple_encoder(struct > > > +drm_encoder *enc) { > > > + return container_of(enc, struct simple_encoder, encoder); } > > > + > > > +static int encoder_parse_dt(struct device *dev) { > > > + struct simple_encoder *simple = dev_get_drvdata(dev); > > > + unsigned int args[2]; > > > + > > > + simple->dss_regmap = &g
RE: [v3 6/6] drm/vs: simple encoder
> -Original Message- > From: Dmitry Baryshkov > Sent: 2024年5月15日 23:17 > To: Keith Zhao > Cc: devicet...@vger.kernel.org; dri-devel@lists.freedesktop.org; > linux-ker...@vger.kernel.org; linux-ri...@lists.infradead.org; > a...@eecs.berkeley.edu; suijingf...@loongson.cn; tzimmerm...@suse.de; > paul.walms...@sifive.com; mrip...@kernel.org; Xingyu Wu > ; Jack Zhu ; > pal...@dabbelt.com; krzysztof.kozlowski...@linaro.org; William Qiu > ; Shengyang Chen > ; Changhuang Liang > > Subject: Re: [v3 6/6] drm/vs: simple encoder > > On Wed, May 15, 2024 at 10:07:27AM +, Keith Zhao wrote: > > > > > > > -Original Message- > > > From: Dmitry Baryshkov > > > Sent: 2023年12月5日 21:19 > > > To: Keith Zhao > > > Cc: devicet...@vger.kernel.org; dri-devel@lists.freedesktop.org; > > > linux-ker...@vger.kernel.org; linux-ri...@lists.infradead.org; > > > a...@eecs.berkeley.edu; suijingf...@loongson.cn; tzimmerm...@suse.de; > > > paul.walms...@sifive.com; mrip...@kernel.org; Xingyu Wu > > > ; Jack Zhu ; > > > pal...@dabbelt.com; krzysztof.kozlowski...@linaro.org; William Qiu > > > ; Shengyang Chen > > > ; Changhuang Liang > > > > > > Subject: Re: [v3 6/6] drm/vs: simple encoder > > > > > > On Tue, 5 Dec 2023 at 15:14, Dmitry Baryshkov > > > > > > wrote: > > > > > > > > On Mon, 4 Dec 2023 at 14:33, Keith Zhao > > > > > > > wrote: > > > > > > > > > > add simple encoder for dsi bridge > > > > > > > > This doesn't look like a proper commit message. > > > > > > > > > > > > > > Signed-off-by: Keith Zhao > > > > > --- > > > > > drivers/gpu/drm/verisilicon/Makefile| 4 +- > > > > > drivers/gpu/drm/verisilicon/vs_drv.c| 2 + > > > > > drivers/gpu/drm/verisilicon/vs_simple_enc.c | 195 > > > > > > > > > > drivers/gpu/drm/verisilicon/vs_simple_enc.h > > > > > | > > > > > 23 +++ > > > > > 4 files changed, 223 insertions(+), 1 deletion(-) create mode > > > > > 100644 drivers/gpu/drm/verisilicon/vs_simple_enc.c > > > > > create mode 100644 drivers/gpu/drm/verisilicon/vs_simple_enc.h > > > > > > > > > > diff --git a/drivers/gpu/drm/verisilicon/Makefile > > > > > b/drivers/gpu/drm/verisilicon/Makefile > > > > > index 71fadafcee13..cd5d0a90bcfe 100644 > > > > > --- a/drivers/gpu/drm/verisilicon/Makefile > > > > > +++ b/drivers/gpu/drm/verisilicon/Makefile > > > > > @@ -5,6 +5,8 @@ vs_drm-objs := vs_dc_hw.o \ > > > > > vs_crtc.o \ > > > > > vs_drv.o \ > > > > > vs_modeset.o \ > > > > > - vs_plane.o > > > > > + vs_plane.o \ > > > > > + vs_simple_enc.o > > > > > + > > > > > vs_drm-$(CONFIG_DRM_VERISILICON_STARFIVE_HDMI) += > > > starfive_hdmi.o > > > > > obj-$(CONFIG_DRM_VERISILICON) += vs_drm.o diff --git > > > > > a/drivers/gpu/drm/verisilicon/vs_drv.c > > > > > b/drivers/gpu/drm/verisilicon/vs_drv.c > > > > > index d7e5199fe293..946f137ab124 100644 > > > > > --- a/drivers/gpu/drm/verisilicon/vs_drv.c > > > > > +++ b/drivers/gpu/drm/verisilicon/vs_drv.c > > > > > @@ -23,6 +23,7 @@ > > > > > #include "vs_drv.h" > > > > > #include "vs_modeset.h" > > > > > #include "vs_dc.h" > > > > > +#include "vs_simple_enc.h" > > > > > > > > > > #define DRV_NAME "verisilicon" > > > > > #define DRV_DESC "Verisilicon DRM driver" > > > > > @@ -217,6 +218,7 @@ static struct platform_driver > > > > > *drm_sub_drivers[] = { #ifdef > CONFIG_DRM_VERISILICON_STARFIVE_HDMI > > > > > &starfive_hdmi_driver, > > > > > #endif > > > > > + &simple_encoder_driver, > > > > > }; > > > > > > > > > > static struct component_match *vs_drm_match_add(struct device > > > > > *dev) diff --git a/drivers/gpu/drm/verisilicon/vs_simple_enc.c > > > > > b/drivers/gpu/drm/verisilicon
RE: [PATCH v4 01/10] dt-bindings: display: Add YAML schema for JH7110 display pipeline
Hi Krzysztof: > -Original Message- > From: Krzysztof Kozlowski > Sent: 2024年5月21日 15:30 > To: Keith Zhao ; andrzej.ha...@intel.com; > neil.armstr...@linaro.org; rf...@kernel.org; > laurent.pinch...@ideasonboard.com; jo...@kwiboo.se; > jernej.skra...@gmail.com; maarten.lankho...@linux.intel.com; > mrip...@kernel.org; tzimmerm...@suse.de; airl...@gmail.com; > dan...@ffwll.ch; r...@kernel.org; krzk...@kernel.org; conor...@kernel.org; > h...@rock-chips.com; he...@sntech.de; andy@rock-chips.com; Xingyu Wu > ; p.za...@pengutronix.de; Jack Zhu > ; Shengyang Chen > > Cc: dri-devel@lists.freedesktop.org; devicet...@vger.kernel.org; > linux-ker...@vger.kernel.org; linux-arm-ker...@lists.infradead.org > Subject: Re: [PATCH v4 01/10] dt-bindings: display: Add YAML schema for JH7110 > display pipeline > > On 21/05/2024 12:58, keith wrote: > > JH7110 SoC display pipeline includes a display controller and hdmi. > > Dc controller IP : Vivante DC8200 Dual Display HDMI IP : INNOSILICON > > HDMI2.0 > > > > As the INNO hdmi ip is also used by rockchip SoC in the driver code, > > the innosilicon,inno-hdmi.yaml schema containing the common properties > > for the INNO DesignWare HDMI TX controller isn't a full device tree > > binding specification, but is meant to be referenced by > > platform-specific bindings for the IP core. > > > > Signed-off-by: keith > > --- > > .../display/bridge/innosilicon,inno-hdmi.yaml | 49 + > > .../display/rockchip/rockchip,inno-hdmi.yaml | 27 +-- > > .../starfive/starfive,dsi-encoder.yaml| 92 ++ > > .../starfive/starfive,jh7110-dc8200.yaml | 169 ++ > > .../starfive/starfive,jh7110-inno-hdmi.yaml | 75 > > .../soc/starfive/starfive,jh7110-syscon.yaml | 1 + > > MAINTAINERS | 8 + > > 7 files changed, 396 insertions(+), 25 deletions(-) create mode > > 100644 > > Documentation/devicetree/bindings/display/bridge/innosilicon,inno-hdmi > > .yaml create mode 100644 > > Documentation/devicetree/bindings/display/starfive/starfive,dsi-encode > > r.yaml create mode 100644 > > Documentation/devicetree/bindings/display/starfive/starfive,jh7110-dc8 > > 200.yaml create mode 100644 > > Documentation/devicetree/bindings/display/starfive/starfive,jh7110-inn > > o-hdmi.yaml > > > > diff --git > > a/Documentation/devicetree/bindings/display/bridge/innosilicon,inno-hd > > mi.yaml > > b/Documentation/devicetree/bindings/display/bridge/innosilicon,inno-hd > > mi.yaml > > new file mode 100644 > > index ..8540174dcaeb > > --- /dev/null > > +++ b/Documentation/devicetree/bindings/display/bridge/innosilicon,inn > > +++ o-hdmi.yaml > > @@ -0,0 +1,49 @@ > > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) %YAML 1.2 > > +--- > > +$id: > > +http://devicetree.org/schemas/display/bridge/innosilicon,inno-hdmi.ya > > +ml# > > +$schema: http://devicetree.org/meta-schemas/core.yaml# > > + > > +title: Common Properties for Innosilicon HDMI TX IP > > Your patch is difficult to review. Split changing existing bindings (and > defining > common part) to a separate patch. The background is that because the existing inno hdmi driver on the main line has some interfaces that can be public, its yaml counterpart attempts to make a public reference file > > > + > > +maintainers: > > + - Keith Zhao > > + > > +description: | > > + This document defines device tree properties for the Innosilicon > > +HDMI TX > > Nothing improved here. Don't say obvious that this documents says something. > It cannot do anything else. > > "Innosilicon HDMI TX is a foo bar device present on zap SoC " > > > > + controller (INNO HDMI) IP core. It doesn't constitute a full device > > + tree binding specification by itself but is meant to be referenced > > + by device tree bindings for the platform-specific integrations of the > > INNO > HDMI. > > I don't understand this at all. I don't know what is "full device tree binding > specification". > > > + > > + When referenced from platform device tree bindings the properties > > + defined in this document are defined as follows. The platform > > + device tree bindings are responsible for defining whether each property > > is > required or optional. > > Nothing improved - drop paragraph. These descriptions are based this file, and because their roles are close, only some key elements have been changed of co
RE: [PATCH v4 02/10] drm/bridge: add common api for inno hdmi
Hi Alex, Laurent: I want to make as few changes as possible on the current basis, and add bridge_fun, > -Original Message- > From: Laurent Pinchart > Sent: 2024年5月21日 23:42 > To: Alex Bee > Cc: Keith Zhao ; andrzej.ha...@intel.com; > neil.armstr...@linaro.org; rf...@kernel.org; jo...@kwiboo.se; > jernej.skra...@gmail.com; maarten.lankho...@linux.intel.com; > mrip...@kernel.org; tzimmerm...@suse.de; airl...@gmail.com; > dan...@ffwll.ch; r...@kernel.org; krzk...@kernel.org; conor...@kernel.org; > h...@rock-chips.com; he...@sntech.de; andy@rock-chips.com; Xingyu Wu > ; p.za...@pengutronix.de; Jack Zhu > ; Shengyang Chen > ; dri-devel@lists.freedesktop.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org > Subject: Re: [PATCH v4 02/10] drm/bridge: add common api for inno hdmi > > On Tue, May 21, 2024 at 05:36:43PM +0200, Alex Bee wrote: > > Hi Keith, > > > > thanks a lot for working on this. See some general remarks below > > > > Am 21.05.24 um 12:58 schrieb keith: > > > Add INNO common api so that it can be used by vendor drivers which > > > implement vendor specific extensions to Innosilicon HDMI. > > > > > > Signed-off-by: keith > > > --- > > > MAINTAINERS | 2 + > > > drivers/gpu/drm/bridge/Kconfig| 2 + > > > drivers/gpu/drm/bridge/Makefile | 1 + > > > drivers/gpu/drm/bridge/innosilicon/Kconfig| 6 + > > > drivers/gpu/drm/bridge/innosilicon/Makefile | 2 + > > > .../gpu/drm/bridge/innosilicon/inno-hdmi.c| 587 > ++ > > > .../gpu/drm/bridge/innosilicon/inno-hdmi.h| 97 +++ > > > include/drm/bridge/inno_hdmi.h| 69 ++ > > > 8 files changed, 766 insertions(+) > > > create mode 100644 drivers/gpu/drm/bridge/innosilicon/Kconfig > > > create mode 100644 drivers/gpu/drm/bridge/innosilicon/Makefile > > > create mode 100644 drivers/gpu/drm/bridge/innosilicon/inno-hdmi.c > > > create mode 100644 drivers/gpu/drm/bridge/innosilicon/inno-hdmi.h > > > create mode 100644 include/drm/bridge/inno_hdmi.h > > > > > > > > > > + drm_encoder_helper_add(encoder, pdata->helper_private); > > > + > > > + hdmi->connector.polled = DRM_CONNECTOR_POLL_HPD; > > > + > > > + drm_connector_helper_add(&hdmi->connector, > > > + &inno_hdmi_connector_helper_funcs); > > > + > > > + drmm_connector_init(drm, &hdmi->connector, > > > + &inno_hdmi_connector_funcs, > > > + DRM_MODE_CONNECTOR_HDMIA, > > > + hdmi->ddc); > > > + > > > > I really don't want to anticipate bridge maintainer's feedback, but > > new bridge drivers must not contain connector creation. That must > > happen somewhere else. > > You're absolutely right :-) Connector creation should be handled by the > drm_bridge_connector helper. The HDMI bridge driver should focus on the > HDMI bridge itself. static int inno_bridge_attach(struct drm_bridge *bridge, enum drm_bridge_attach_flags flags) { struct inno_hdmi *hdmi = bridge_to_inno(bridge); if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) { DRM_ERROR("Fix bridge driver to make connector optional!"); return -EINVAL; } hdmi->connector.polled = DRM_CONNECTOR_POLL_HPD; drm_connector_helper_add(&hdmi->connector, &inno_hdmi_connector_helper_funcs); drmm_connector_init(drm, &hdmi->connector, &inno_hdmi_connector_funcs, DRM_MODE_CONNECTOR_HDMIA, hdmi->ddc); drm_connector_attach_encoder(&hdmi->connector, encoder); } static const struct drm_bridge_funcs inno_bridge_attach = { .attach = inno_bridge_attach, }; Connector creation is handled by the drm_bridge_funcs ->attach. Is it ok? Regards Keith > > > Also I'm neither seeing any drm_brige struct nor drm_bridge_funcs, > > which are both essential for a bridge driver. I don't think moving a > > part of a driver to .../drm/bridge/ makes it a bridge driver. > > > > > + drm_connector_attach_encoder(&hdmi->connector, encoder); > > > + > > > + return 0; > > > +} > > > + > > > > > > -- > Regards, > > Laurent Pinchart
Re: [PATCH v2 1/6] dt-bindings: display: Add yamls for JH7110 display system
On 2023/10/25 20:50, Krzysztof Kozlowski wrote: > On 25/10/2023 12:39, Keith Zhao wrote: >> StarFive SoCs JH7110 display system: > > A nit, subject: drop second/last, redundant "yamls for". The > "dt-bindings" prefix is already stating that these are bindings, so > format is fixed. > >> lcd-controller bases verisilicon dc8200 IP, >> and hdmi bases Innosilicon IP. Add bindings for them. > > Please make it a proper sentences, with proper wrapping. > >> >> also update MAINTAINERS for dt-bindings > > Not a sentence, but also not really needed.ok I see. > >> >> about this patch, I tested the dtbs_check and dt_binding_check >> with the result pass. >> Based on the feedback of the previous version, the corresponding arrangement >> is made > > Not relevant, so not really suitable for commit msg. > >> >> Signed-off-by: Keith Zhao >> --- >> .../starfive/starfive,display-subsystem.yaml | 41 +++ >> .../starfive/starfive,jh7110-dc8200.yaml | 109 ++ >> .../starfive/starfive,jh7110-inno-hdmi.yaml | 85 ++ >> MAINTAINERS | 7 ++ >> 4 files changed, 242 insertions(+) >> create mode 100644 >> Documentation/devicetree/bindings/display/starfive/starfive,display-subsystem.yaml >> create mode 100644 >> Documentation/devicetree/bindings/display/starfive/starfive,jh7110-dc8200.yaml >> create mode 100644 >> Documentation/devicetree/bindings/display/starfive/starfive,jh7110-inno-hdmi.yaml >> >> diff --git >> a/Documentation/devicetree/bindings/display/starfive/starfive,display-subsystem.yaml >> >> b/Documentation/devicetree/bindings/display/starfive/starfive,display-subsystem.yaml >> new file mode 100644 >> index 0..f45b97b08 >> --- /dev/null >> +++ >> b/Documentation/devicetree/bindings/display/starfive/starfive,display-subsystem.yaml >> @@ -0,0 +1,41 @@ >> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) >> +%YAML 1.2 >> +--- >> +$id: >> http://devicetree.org/schemas/display/starfive/starfive,display-subsystem.yaml# >> +$schema: http://devicetree.org/meta-schemas/core.yaml# >> + >> +title: Starfive DRM master device > > What is DRM in hardware? I know Digital Rights Management, but then > subsystem seems wrong. If you mean Linux DRM, then Linux is not a > hardware, so drop all Linuxisms and describe hardware. ok , will only keep hardware describe in my next version > > >> + >> +maintainers: >> + - Keith Zhao >> + - ShengYang Chen >> + >> +description: >> + The Starfive DRM master device is a virtual device needed to list all > > Virtual device? Then not suitable for bindings, sorry. > >> + display controller or other display interface nodes that comprise the >> + graphics subsystem. >> + >> +properties: >> + compatible: >> +const: starfive,display-subsystem >> + >> + ports: >> +$ref: /schemas/types.yaml#/definitions/phandle-array > > No, ports is not phandle-array. ports is object, always. > >> +description: >> + Should contain a list of phandles pointing to display interface ports >> + of display controller devices. Display controller definitions as >> defined >> + in Documentation/devicetree/bindings/display/starfive/ >> + starfive,jh7110-dc8200.yaml > > Use standard graph ports, not some own, custom property. > > Anyway, entire binding should be dropped. You do not need it even. Hi Krzysztof: Virtual device is not suitable for bindings, matbe I need associate it with the real hardware. such as the top clocks & reset , irq , etc. Currently I configure them in another yaml file. Logically speaking, this is more suitable. Can adding the corresponding hardware description change its fate of being deleted? > >> + >> +required: >> + - compatible >> + - ports >> + >> +additionalProperties: false >> + >> +examples: >> + - | >> +display-subsystem { >> +compatible = "starfive,display-subsystem"; >> +ports = <&dc_out>; >> +}; >> diff --git >> a/Documentation/devicetree/bindings/display/starfive/starfive,jh7110-dc8200.yaml >> >> b/Documentation/devicetree/bindings/display/starfive/starfive,jh7110-dc8200.yaml >> new file mode 100644 >> index 00000..87051cddf >> --- /dev/null >> +++ >> b/Documentation/devicetree/bindings/display/starfive/starfive,jh7110-dc8200.y
[v3 2/6] riscv: dts: starfive: jh7110: display subsystem
Add the dc controller and hdmi node for the Starfive JH7110 SoC. Signed-off-by: Keith Zhao --- .../jh7110-starfive-visionfive-2.dtsi | 134 ++ arch/riscv/boot/dts/starfive/jh7110.dtsi | 49 +++ 2 files changed, 183 insertions(+) diff --git a/arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-2.dtsi b/arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-2.dtsi index b89e9791efa7..6e387e0138c0 100644 --- a/arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-2.dtsi +++ b/arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-2.dtsi @@ -35,6 +35,25 @@ memory@4000 { reg = <0x0 0x4000 0x1 0x0>; }; + reserved-memory { + #address-cells = <2>; + #size-cells = <2>; + ranges; + + /* vout applies for space from this CMA +* Without this CMA reservation, +* vout may not work properly. +*/ + linux,cma { + compatible = "shared-dma-pool"; + reusable; + size = <0x0 0x2000>; + alignment = <0x0 0x1000>; + alloc-ranges = <0x0 0x7000 0x0 0x2000>; + linux,cma-default; + }; + }; + gpio-restart { compatible = "gpio-restart"; gpios = <&sysgpio 35 GPIO_ACTIVE_HIGH>; @@ -69,6 +88,68 @@ codec { }; }; +&dc8200 { + status = "okay"; + + crtc_out: ports { + #address-cells = <1>; + #size-cells = <0>; + + dc_out0: port@0 { + reg = <0>; + #address-cells = <1>; + #size-cells = <0>; + + dc_out_dpi0: endpoint@0 { + reg = <0>; + remote-endpoint = <&hdmi_enc>; + }; + + }; + + dc_out1: port@1 { + reg = <1>; + #address-cells = <1>; + #size-cells = <0>; + + dc_out_dpi1: endpoint@1 { + reg = <1>; + remote-endpoint = <&dsi_enc>; + }; + + }; + }; +}; + +&display { + status = "okay"; + ports = <&crtc_out>; +}; + +&dsi_encoder { + status = "okay"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + /* input */ + enc_in: port@0 { + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + dsi_enc:endpoint@0 { + reg = <0>; + remote-endpoint = <&dc_out_dpi1>; + }; + }; + /* output */ + enc_out: port@1 { + reg = <1>; + /*need add a remote-endpoint to dsi bridge*/ + }; + }; +}; + &dvp_clk { clock-frequency = <7425>; }; @@ -89,6 +170,21 @@ &gmac1_rmii_refin { clock-frequency = <5000>; }; +&hdmi { + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <&hdmi_pins>; + + hdmi_in: port { + #address-cells = <1>; + #size-cells = <0>; + hdmi_enc: endpoint@0 { + reg = <0>; + remote-endpoint = <&dc_out_dpi0>; + }; + }; +}; + &hdmitx0_pixelclk { clock-frequency = <29700>; }; @@ -336,6 +432,40 @@ spi_dev0: spi@0 { }; &sysgpio { + hdmi_pins: hdmi-0 { + hdmi-cec-pins { + pinmux = ; + input-enable; + bias-pull-up; + }; + + hdmi-hpd-pins { + pinmux = ; + input-enable; + bias-disable; /* external pull-up */ + }; + + hdmi-scl-pins { + pinmux = ; + input-enable; + bias-pull-up; + }; + + hdmi-sda-pins { + pinmux = ; + input-enable; + bias-pull-up; + }; + }; + i2c0_pins: i2c0-0 { i2c-pins { pinmux = ; }; + +&
[v3 1/6] dt-bindings: display: Add yamls for JH7110 display system
StarFive SoCs JH7110 display system: dc controller, hdmi controller, encoder, vout syscon. add the path of yaml file in MAINTAINERS Signed-off-by: Keith Zhao --- .../starfive/starfive,display-subsystem.yaml | 104 .../starfive/starfive,dsi-encoder.yaml| 92 ++ .../starfive/starfive,jh7110-dc8200.yaml | 113 ++ .../starfive/starfive,jh7110-inno-hdmi.yaml | 82 + .../soc/starfive/starfive,jh7110-syscon.yaml | 1 + MAINTAINERS | 7 ++ 6 files changed, 399 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/starfive/starfive,display-subsystem.yaml create mode 100644 Documentation/devicetree/bindings/display/starfive/starfive,dsi-encoder.yaml create mode 100644 Documentation/devicetree/bindings/display/starfive/starfive,jh7110-dc8200.yaml create mode 100644 Documentation/devicetree/bindings/display/starfive/starfive,jh7110-inno-hdmi.yaml diff --git a/Documentation/devicetree/bindings/display/starfive/starfive,display-subsystem.yaml b/Documentation/devicetree/bindings/display/starfive/starfive,display-subsystem.yaml new file mode 100644 index ..d5ebdba3fb36 --- /dev/null +++ b/Documentation/devicetree/bindings/display/starfive/starfive,display-subsystem.yaml @@ -0,0 +1,104 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/starfive/starfive,display-subsystem.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Starfive JH7110 Soc Display SubSystem + +maintainers: + - Keith Zhao + - ShengYang Chen + +description: + This is the bindings documentation for the JH7110 Soc Display Subsystem that + includes front-end video data capture, display controller and display + interface. such as HDMI and MIPI. + + JH7110 display pipeline have several components as below description, + multi display controllers and corresponding physical interfaces. + For different display scenarios, pipe0 and pipe1 maybe binding to different + encoder. for example, + + pipe0 binding to HDMI for primary display, + pipe1 binding to DSI for external display. + + +--+ + | | + | | + ++ | +---+ | +---+ +--+ +--+ + |+->+ dc controller 0 +--->->+HDMICtl| ->+ PHY +-->+PANEL0+ + |AXI | | +---+ | +---+ +--+ +--+ + || | | + || | | + || | | + || | | + |APB | | +---+ +-++--+ +---+ + |+->+ dc controller 1 +--->>+ dsiTx +--->+DPHY +->+ PANEL1+ + || | +---+ +-++--+ +---+ + ++ | | + +--+ + + +properties: + compatible: +const: starfive,display-subsystem + + clocks: +items: + - description: Clock for display system noc bus. + - description: Core clock for display controller. + - description: Clock for axi bus to access ddr. + - description: Clock for ahb bus to R/W the phy regs. + + clock-names: +items: + - const: noc_bus + - const: dc_core + - const: axi_core + - const: ahb + + resets: +items: + - description: Reset for axi bus. + - description: Reset for ahb bus. + - description: Core reset of display controller. + + reset-names: +items: + - const: axi + - const: ahb + - const: core + + ports: +$ref: /schemas/types.yaml#/definitions/phandle-array +items: + maxItems: 1 +description: + Should contain a list of phandles pointing to display interface port + of dc-controller devices. + +required: + - compatible + - clocks + - clock-names + - resets + - reset-names + - ports + +additionalProperties: false + +examples: + - | +display-subsystem { +compatible = "starfive,display-subsystem"; +ports = <&dc_out>; + +clocks = <&syscrg 60>, + <&voutcrg 4>, + <&voutcrg 5>, + <&voutcrg 6>; +clock-names = "noc_bus", "dc_core", "axi_core", "ahb"; +resets = <&voutcrg 0>, <&voutcrg 1>, <&voutcrg 2>; +reset-names = "axi", "ahb", "core"; +}; diff --git a/Documentation/devicetree/bindings/display/starfive/starfive,dsi-encoder.yaml b/Documentation/devicetree/bindings/display/starfive/starfive,dsi-encoder.yaml new file mode 100644 index ..2cc0ad8e65ba ---
[v3 6/6] drm/vs: simple encoder
add simple encoder for dsi bridge Signed-off-by: Keith Zhao --- drivers/gpu/drm/verisilicon/Makefile| 4 +- drivers/gpu/drm/verisilicon/vs_drv.c| 2 + drivers/gpu/drm/verisilicon/vs_simple_enc.c | 195 drivers/gpu/drm/verisilicon/vs_simple_enc.h | 23 +++ 4 files changed, 223 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/verisilicon/vs_simple_enc.c create mode 100644 drivers/gpu/drm/verisilicon/vs_simple_enc.h diff --git a/drivers/gpu/drm/verisilicon/Makefile b/drivers/gpu/drm/verisilicon/Makefile index 71fadafcee13..cd5d0a90bcfe 100644 --- a/drivers/gpu/drm/verisilicon/Makefile +++ b/drivers/gpu/drm/verisilicon/Makefile @@ -5,6 +5,8 @@ vs_drm-objs := vs_dc_hw.o \ vs_crtc.o \ vs_drv.o \ vs_modeset.o \ - vs_plane.o + vs_plane.o \ + vs_simple_enc.o + vs_drm-$(CONFIG_DRM_VERISILICON_STARFIVE_HDMI) += starfive_hdmi.o obj-$(CONFIG_DRM_VERISILICON) += vs_drm.o diff --git a/drivers/gpu/drm/verisilicon/vs_drv.c b/drivers/gpu/drm/verisilicon/vs_drv.c index d7e5199fe293..946f137ab124 100644 --- a/drivers/gpu/drm/verisilicon/vs_drv.c +++ b/drivers/gpu/drm/verisilicon/vs_drv.c @@ -23,6 +23,7 @@ #include "vs_drv.h" #include "vs_modeset.h" #include "vs_dc.h" +#include "vs_simple_enc.h" #define DRV_NAME "verisilicon" #define DRV_DESC "Verisilicon DRM driver" @@ -217,6 +218,7 @@ static struct platform_driver *drm_sub_drivers[] = { #ifdef CONFIG_DRM_VERISILICON_STARFIVE_HDMI &starfive_hdmi_driver, #endif + &simple_encoder_driver, }; static struct component_match *vs_drm_match_add(struct device *dev) diff --git a/drivers/gpu/drm/verisilicon/vs_simple_enc.c b/drivers/gpu/drm/verisilicon/vs_simple_enc.c new file mode 100644 index ..c5a8d82bc469 --- /dev/null +++ b/drivers/gpu/drm/verisilicon/vs_simple_enc.c @@ -0,0 +1,195 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2020 VeriSilicon Holdings Co., Ltd. + */ +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "vs_crtc.h" +#include "vs_simple_enc.h" + +static const struct simple_encoder_priv dsi_priv = { + .encoder_type = DRM_MODE_ENCODER_DSI +}; + +static inline struct simple_encoder *to_simple_encoder(struct drm_encoder *enc) +{ + return container_of(enc, struct simple_encoder, encoder); +} + +static int encoder_parse_dt(struct device *dev) +{ + struct simple_encoder *simple = dev_get_drvdata(dev); + unsigned int args[2]; + + simple->dss_regmap = syscon_regmap_lookup_by_phandle_args(dev->of_node, + "starfive,syscon", + 2, args); + + if (IS_ERR(simple->dss_regmap)) { + return dev_err_probe(dev, PTR_ERR(simple->dss_regmap), +"getting the regmap failed\n"); + } + + simple->offset = args[0]; + simple->mask = args[1]; + + return 0; +} + +void encoder_atomic_enable(struct drm_encoder *encoder, + struct drm_atomic_state *state) +{ + struct simple_encoder *simple = to_simple_encoder(encoder); + + regmap_update_bits(simple->dss_regmap, simple->offset, simple->mask, + simple->mask); +} + +int encoder_atomic_check(struct drm_encoder *encoder, +struct drm_crtc_state *crtc_state, +struct drm_connector_state *conn_state) +{ + struct vs_crtc_state *vs_crtc_state = to_vs_crtc_state(crtc_state); + struct drm_connector *connector = conn_state->connector; + int ret = 0; + + struct drm_bridge *first_bridge = drm_bridge_chain_get_first_bridge(encoder); + struct drm_bridge_state *bridge_state = ERR_PTR(-EINVAL); + + vs_crtc_state->encoder_type = encoder->encoder_type; + + if (first_bridge && first_bridge->funcs->atomic_duplicate_state) + bridge_state = drm_atomic_get_bridge_state(crtc_state->state, first_bridge); + + if (IS_ERR(bridge_state)) { + if (connector->display_info.num_bus_formats) + vs_crtc_state->output_fmt = connector->display_info.bus_formats[0]; + else + vs_crtc_state->output_fmt = MEDIA_BUS_FMT_FIXED; + } else { + vs_crtc_state->output_fmt = bridge_state->input_bus_cfg.format; + } + + switch (vs_crtc_state->output_fmt) { + case MEDIA_BUS_FMT_FIXED: + case MEDIA_BUS_FMT_RGB565_1X16: + case MEDIA_BUS_FMT_RGB666_1X18: + case MEDIA_BUS_FMT_RGB888_1X24: + case MEDIA_BUS_
[v3 5/6] drm/vs: Add hdmi driver
add hdmi driver as encoder and connect Signed-off-by: Keith Zhao --- drivers/gpu/drm/verisilicon/Kconfig | 8 + drivers/gpu/drm/verisilicon/Makefile| 1 + drivers/gpu/drm/verisilicon/starfive_hdmi.c | 849 drivers/gpu/drm/verisilicon/starfive_hdmi.h | 304 +++ drivers/gpu/drm/verisilicon/vs_drv.c| 3 + drivers/gpu/drm/verisilicon/vs_drv.h| 4 + 6 files changed, 1169 insertions(+) create mode 100644 drivers/gpu/drm/verisilicon/starfive_hdmi.c create mode 100644 drivers/gpu/drm/verisilicon/starfive_hdmi.h diff --git a/drivers/gpu/drm/verisilicon/Kconfig b/drivers/gpu/drm/verisilicon/Kconfig index e10fa97635aa..122c786e3948 100644 --- a/drivers/gpu/drm/verisilicon/Kconfig +++ b/drivers/gpu/drm/verisilicon/Kconfig @@ -11,3 +11,11 @@ config DRM_VERISILICON This driver provides VeriSilicon kernel mode setting and buffer management. It does not provide 2D or 3D acceleration. + +config DRM_VERISILICON_STARFIVE_HDMI + bool "Starfive HDMI extensions" + depends on DRM_VERISILICON + help + This selects support for StarFive soc specific extensions + for the Innosilicon HDMI driver. If you want to enable + HDMI on JH7110 based soc, you should select this option. diff --git a/drivers/gpu/drm/verisilicon/Makefile b/drivers/gpu/drm/verisilicon/Makefile index bf6f2b7ee480..71fadafcee13 100644 --- a/drivers/gpu/drm/verisilicon/Makefile +++ b/drivers/gpu/drm/verisilicon/Makefile @@ -6,4 +6,5 @@ vs_drm-objs := vs_dc_hw.o \ vs_drv.o \ vs_modeset.o \ vs_plane.o +vs_drm-$(CONFIG_DRM_VERISILICON_STARFIVE_HDMI) += starfive_hdmi.o obj-$(CONFIG_DRM_VERISILICON) += vs_drm.o diff --git a/drivers/gpu/drm/verisilicon/starfive_hdmi.c b/drivers/gpu/drm/verisilicon/starfive_hdmi.c new file mode 100644 index ..aa621db0dee0 --- /dev/null +++ b/drivers/gpu/drm/verisilicon/starfive_hdmi.c @@ -0,0 +1,849 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2023 StarFive Technology Co., Ltd. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "starfive_hdmi.h" +#include "vs_drv.h" +#include "vs_crtc.h" + +static const char * const hdmi_clocks[] = { + "sysclk", + "mclk", + "bclk" +}; + +static struct starfive_hdmi_encoder *encoder_to_hdmi(struct drm_encoder *encoder) +{ + return container_of(encoder, struct starfive_hdmi_encoder, encoder); +} + +static struct starfive_hdmi *connector_to_hdmi(struct drm_connector *connector) +{ + return container_of(connector, struct starfive_hdmi, connector); +} + +static const struct post_pll_config post_pll_cfg_table[] = { + {2520, 1, 80, 13, 3, 1}, + {2700, 1, 40, 11, 3, 1}, + {3375, 1, 40, 11, 3, 1}, + {4900, 1, 20, 1, 3, 3}, + {24170, 1, 20, 1, 3, 3}, + {29700, 4, 20, 0, 0, 3}, + {59400, 4, 20, 0, 0, 0}, + { /* sentinel */ } +}; + +inline u8 hdmi_readb(struct starfive_hdmi *hdmi, u16 offset) +{ + return readl_relaxed(hdmi->regs + (offset) * 0x04); +} + +inline void hdmi_writeb(struct starfive_hdmi *hdmi, u16 offset, u32 val) +{ + writel_relaxed(val, hdmi->regs + (offset) * 0x04); +} + +inline void hdmi_writew(struct starfive_hdmi *hdmi, u16 offset, u32 val) +{ + writew_relaxed(val & 0xFF, hdmi->regs + (offset) * 0x04); + writew_relaxed((val >> 8) & 0xFF, hdmi->regs + (offset + 1) * 0x04); +} + +inline void hdmi_modb(struct starfive_hdmi *hdmi, u16 offset, +u32 msk, u32 val) +{ + u8 temp = hdmi_readb(hdmi, offset) & ~msk; + + temp |= val & msk; + hdmi_writeb(hdmi, offset, temp); +} + +static int starfive_hdmi_enable_clk_deassert_rst(struct device *dev, struct starfive_hdmi *hdmi) +{ + int ret; + + ret = clk_bulk_prepare_enable(hdmi->nclks, hdmi->clk_hdmi); + if (ret) { + dev_err(dev, "failed to enable clocks\n"); + return ret; + } + + ret = reset_control_deassert(hdmi->tx_rst); + if (ret < 0) { + dev_err(dev, "failed to deassert tx_rst\n"); + return ret; + } + return 0; +} + +static void starfive_hdmi_disable_clk_assert_rst(struct device *dev, struct starfive_hdmi *hdmi) +{ + int ret; + + ret = reset_control_assert(hdmi->tx_rst); + if (ret < 0) + dev_err(dev, "failed to assert tx_rst\n"); + + clk_bulk_disable_unprepare(hdmi->nclks, hdmi->clk_hdmi); +} + +#ifdef CONFIG_PM_SLEEP +static int hdmi_syste
[v3 3/6] drm/vs: Register DRM device
Implement drm device registration interface Signed-off-by: Keith Zhao --- MAINTAINERS | 1 + drivers/gpu/drm/Kconfig | 2 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/verisilicon/Kconfig | 13 + drivers/gpu/drm/verisilicon/Makefile | 6 + drivers/gpu/drm/verisilicon/vs_drv.c | 316 +++ drivers/gpu/drm/verisilicon/vs_drv.h | 42 +++ drivers/gpu/drm/verisilicon/vs_modeset.c | 39 +++ drivers/gpu/drm/verisilicon/vs_modeset.h | 10 + 9 files changed, 430 insertions(+) create mode 100644 drivers/gpu/drm/verisilicon/Kconfig create mode 100644 drivers/gpu/drm/verisilicon/Makefile create mode 100644 drivers/gpu/drm/verisilicon/vs_drv.c create mode 100644 drivers/gpu/drm/verisilicon/vs_drv.h create mode 100644 drivers/gpu/drm/verisilicon/vs_modeset.c create mode 100644 drivers/gpu/drm/verisilicon/vs_modeset.h diff --git a/MAINTAINERS b/MAINTAINERS index 7caaadb83f3f..8dc9ebfe4605 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6887,6 +6887,7 @@ L:dri-devel@lists.freedesktop.org S: Maintained T: git git://anongit.freedesktop.org/drm/drm-misc F: Documentation/devicetree/bindings/display/starfive/ +F: drivers/gpu/drm/verisilicon/ DRM DRIVER FOR TI DLPC3433 MIPI DSI TO DMD BRIDGE M: Jagan Teki diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index 3eee8636f847..e8d53c2e7c86 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -394,6 +394,8 @@ source "drivers/gpu/drm/solomon/Kconfig" source "drivers/gpu/drm/sprd/Kconfig" +source "drivers/gpu/drm/verisilicon/Kconfig" + config DRM_HYPERV tristate "DRM Support for Hyper-V synthetic video device" depends on DRM && PCI && MMU && HYPERV diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index 8e1bde059170..29e04acded06 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -198,3 +198,4 @@ obj-$(CONFIG_DRM_HYPERV) += hyperv/ obj-y += solomon/ obj-$(CONFIG_DRM_SPRD) += sprd/ obj-$(CONFIG_DRM_LOONGSON) += loongson/ +obj-$(CONFIG_DRM_VERISILICON) += verisilicon/ diff --git a/drivers/gpu/drm/verisilicon/Kconfig b/drivers/gpu/drm/verisilicon/Kconfig new file mode 100644 index ..e10fa97635aa --- /dev/null +++ b/drivers/gpu/drm/verisilicon/Kconfig @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-2.0 +config DRM_VERISILICON + tristate "DRM Support for VeriSilicon" + depends on DRM + select DRM_KMS_HELPER + select DRM_GEM_DMA_HELPER + select CMA + select DMA_CMA + help + Choose this option if you have a VeriSilicon soc chipset. + This driver provides VeriSilicon kernel mode + setting and buffer management. It does not + provide 2D or 3D acceleration. diff --git a/drivers/gpu/drm/verisilicon/Makefile b/drivers/gpu/drm/verisilicon/Makefile new file mode 100644 index ..d785a1dfaa7f --- /dev/null +++ b/drivers/gpu/drm/verisilicon/Makefile @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0 + +vs_drm-objs := vs_drv.o \ + vs_modeset.o + +obj-$(CONFIG_DRM_VERISILICON) += vs_drm.o diff --git a/drivers/gpu/drm/verisilicon/vs_drv.c b/drivers/gpu/drm/verisilicon/vs_drv.c new file mode 100644 index ..4fb1f29ef84b --- /dev/null +++ b/drivers/gpu/drm/verisilicon/vs_drv.c @@ -0,0 +1,316 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2023 VeriSilicon Holdings Co., Ltd. + */ +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "vs_drv.h" +#include "vs_modeset.h" + +#define DRV_NAME "verisilicon" +#define DRV_DESC "Verisilicon DRM driver" +#define DRV_DATE "20230516" +#define DRV_MAJOR 1 +#define DRV_MINOR 0 + +static int vs_gem_dumb_create(struct drm_file *file, struct drm_device *dev, + struct drm_mode_create_dumb *args) +{ + struct vs_drm_device *priv = to_vs_drm_private(dev); + unsigned int pitch = DIV_ROUND_UP(args->width * args->bpp, 8); + + args->pitch = ALIGN(pitch, priv->pitch_alignment); + return drm_gem_dma_dumb_create_internal(file, dev, args); +} + +DEFINE_DRM_GEM_FOPS(vs_drm_fops); + +static struct drm_driver vs_drm_driver = { + .driver_features= DRIVER_MODESET | DRIVER_ATOMIC | DRIVER_GEM, + + DRM_GEM_DMA_DRIVER_OPS_WITH_DUMB_CREATE(vs_gem_dumb_create), + + .fops = &vs_drm_fops, + .name = DRV_NAME, + .desc = DRV_DESC, + .date = DRV_DATE, + .major = DRV_MAJOR, + .minor
dri-devel@lists.freedesktop.org
add 2 crtcs and 8 planes in vs-drm Signed-off-by: Keith Zhao --- drivers/gpu/drm/verisilicon/Makefile |9 +- drivers/gpu/drm/verisilicon/vs_crtc.c | 208 + drivers/gpu/drm/verisilicon/vs_crtc.h | 42 + drivers/gpu/drm/verisilicon/vs_dc.c| 1192 drivers/gpu/drm/verisilicon/vs_dc.h| 67 ++ drivers/gpu/drm/verisilicon/vs_dc_hw.c | 1022 drivers/gpu/drm/verisilicon/vs_dc_hw.h | 580 drivers/gpu/drm/verisilicon/vs_drv.c |2 + drivers/gpu/drm/verisilicon/vs_plane.c | 301 ++ drivers/gpu/drm/verisilicon/vs_plane.h | 39 + drivers/gpu/drm/verisilicon/vs_type.h | 69 ++ 11 files changed, 3528 insertions(+), 3 deletions(-) create mode 100644 drivers/gpu/drm/verisilicon/vs_crtc.c create mode 100644 drivers/gpu/drm/verisilicon/vs_crtc.h create mode 100644 drivers/gpu/drm/verisilicon/vs_dc.c create mode 100644 drivers/gpu/drm/verisilicon/vs_dc.h create mode 100644 drivers/gpu/drm/verisilicon/vs_dc_hw.c create mode 100644 drivers/gpu/drm/verisilicon/vs_dc_hw.h create mode 100644 drivers/gpu/drm/verisilicon/vs_plane.c create mode 100644 drivers/gpu/drm/verisilicon/vs_plane.h create mode 100644 drivers/gpu/drm/verisilicon/vs_type.h diff --git a/drivers/gpu/drm/verisilicon/Makefile b/drivers/gpu/drm/verisilicon/Makefile index d785a1dfaa7f..bf6f2b7ee480 100644 --- a/drivers/gpu/drm/verisilicon/Makefile +++ b/drivers/gpu/drm/verisilicon/Makefile @@ -1,6 +1,9 @@ # SPDX-License-Identifier: GPL-2.0 -vs_drm-objs := vs_drv.o \ - vs_modeset.o - +vs_drm-objs := vs_dc_hw.o \ + vs_dc.o \ + vs_crtc.o \ + vs_drv.o \ + vs_modeset.o \ + vs_plane.o obj-$(CONFIG_DRM_VERISILICON) += vs_drm.o diff --git a/drivers/gpu/drm/verisilicon/vs_crtc.c b/drivers/gpu/drm/verisilicon/vs_crtc.c new file mode 100644 index ..5581219b1230 --- /dev/null +++ b/drivers/gpu/drm/verisilicon/vs_crtc.c @@ -0,0 +1,208 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2023 VeriSilicon Holdings Co., Ltd. + * + */ + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "vs_crtc.h" +#include "vs_dc.h" +#include "vs_drv.h" + +static void vs_crtc_atomic_destroy_state(struct drm_crtc *crtc, +struct drm_crtc_state *state) +{ + __drm_atomic_helper_crtc_destroy_state(state); + kfree(to_vs_crtc_state(state)); +} + +static void vs_crtc_reset(struct drm_crtc *crtc) +{ + struct vs_crtc_state *state; + + if (crtc->state) + vs_crtc_atomic_destroy_state(crtc, crtc->state); + + state = kzalloc(sizeof(*state), GFP_KERNEL); + if (!state) + return; + + __drm_atomic_helper_crtc_reset(crtc, &state->base); +} + +static struct drm_crtc_state * +vs_crtc_atomic_duplicate_state(struct drm_crtc *crtc) +{ + struct vs_crtc_state *old_state; + struct vs_crtc_state *state; + + if (!crtc->state) + return NULL; + + old_state = to_vs_crtc_state(crtc->state); + + state = kmemdup(old_state, sizeof(*old_state), GFP_KERNEL); + if (!state) + return NULL; + + __drm_atomic_helper_crtc_duplicate_state(crtc, &state->base); + + return &state->base; +} + +static int vs_crtc_enable_vblank(struct drm_crtc *crtc) +{ + struct vs_crtc *vs_crtc = to_vs_crtc(crtc); + struct vs_dc *dc = dev_get_drvdata(vs_crtc->dev); + + vs_dc_enable_vblank(dc, true); + + return 0; +} + +static void vs_crtc_disable_vblank(struct drm_crtc *crtc) +{ + struct vs_crtc *vs_crtc = to_vs_crtc(crtc); + struct vs_dc *dc = dev_get_drvdata(vs_crtc->dev); + + vs_dc_enable_vblank(dc, false); +} + +static void vs_crtc_atomic_print_state(struct drm_printer *p, + const struct drm_crtc_state *state) +{ + struct vs_crtc *vs_crtc = to_vs_crtc(state->crtc); + + drm_printf(p, "vs crtc State\n"); + drm_printf(p, "\tcolor_formats: %d\n", vs_crtc->color_formats); + drm_printf(p, "\tmax_bpc: %d\n", vs_crtc->max_bpc); +} + +static const struct drm_crtc_funcs vs_crtc_funcs = { + .set_config = drm_atomic_helper_set_config, + .page_flip = drm_atomic_helper_page_flip, + .reset = vs_crtc_reset, + .atomic_duplicate_state = vs_crtc_atomic_duplicate_state, + .atomic_destroy_state = vs_crtc_atomic_destroy_state, + .enable_vblank = vs_crtc_enable_vblank, + .disable_vblank = vs_crtc_disable_vblank, + .atomic_print_state = vs_crtc_atomic_print_state, +}; + +static void vs_crtc_atomic_enable(struct drm_crtc *crtc, + struct drm_atomic_state *state) +{
[v3 0/6] DRM driver for verisilicon
This patch is a drm driver for Starfive Soc JH7110, I am sending Drm driver part and HDMI driver part. We used GEM framework for buffer management, and for buffer allocation,we use DMA APIs. the Starfive HDMI servers as interface between a LCD Controller and a HDMI bus. A HDMI TX consists of one HDMI transmitter controller and one HDMI transmitter PHY. (Sound support is not include in this patch) This patchset should be applied on next branch. V1: Changes since v1: - Further standardize the yaml file. - Dts naming convention improved. - Fix the problem of compiling and loading ko files. - Use drm new api to automatically manage resources. - Drop vs_crtc_funcs&vs_plane_funcs, subdivide the plane's help interface. - Reduce the modifiers unused. - Optimize the hdmi driver code V2: Changes since v2: - fix the error about checking the yaml file. - match drm driver GEM DMA API. - Delete the custom crtc property . - hdmi use drmm_ new api to automatically manage resources. - update the modifiers comments. - enabling KASAN, fix the error during removing module V3: Changes since v3: - Delete the custom plane property. - Delete the custom fourcc modifiers. - Adjust the calculation mode of hdmi pixclock. - Add match data for dc8200 driver. - Adjust some magic values. - Add a simple encoder for dsi output. Keith Zhao (6): dt-bindings: display: Add yamls for JH7110 display system riscv: dts: starfive: jh7110: display subsystem drm/vs: Register DRM device drm/vs: Add KMS crtc&plane drm/vs: Add hdmi driver drm/vs: simple encoder .../starfive/starfive,display-subsystem.yaml | 104 ++ .../starfive/starfive,dsi-encoder.yaml| 92 ++ .../starfive/starfive,jh7110-dc8200.yaml | 113 ++ .../starfive/starfive,jh7110-inno-hdmi.yaml | 82 ++ .../soc/starfive/starfive,jh7110-syscon.yaml |1 + MAINTAINERS |8 + .../jh7110-starfive-visionfive-2.dtsi | 134 ++ arch/riscv/boot/dts/starfive/jh7110.dtsi | 49 + drivers/gpu/drm/Kconfig |2 + drivers/gpu/drm/Makefile |1 + drivers/gpu/drm/verisilicon/Kconfig | 21 + drivers/gpu/drm/verisilicon/Makefile | 12 + drivers/gpu/drm/verisilicon/starfive_hdmi.c | 849 drivers/gpu/drm/verisilicon/starfive_hdmi.h | 304 + drivers/gpu/drm/verisilicon/vs_crtc.c | 208 +++ drivers/gpu/drm/verisilicon/vs_crtc.h | 42 + drivers/gpu/drm/verisilicon/vs_dc.c | 1192 + drivers/gpu/drm/verisilicon/vs_dc.h | 67 + drivers/gpu/drm/verisilicon/vs_dc_hw.c| 1022 ++ drivers/gpu/drm/verisilicon/vs_dc_hw.h| 580 drivers/gpu/drm/verisilicon/vs_drv.c | 323 + drivers/gpu/drm/verisilicon/vs_drv.h | 46 + drivers/gpu/drm/verisilicon/vs_modeset.c | 39 + drivers/gpu/drm/verisilicon/vs_modeset.h | 10 + drivers/gpu/drm/verisilicon/vs_plane.c| 301 + drivers/gpu/drm/verisilicon/vs_plane.h| 39 + drivers/gpu/drm/verisilicon/vs_simple_enc.c | 195 +++ drivers/gpu/drm/verisilicon/vs_simple_enc.h | 23 + drivers/gpu/drm/verisilicon/vs_type.h | 69 + 29 files changed, 5928 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/starfive/starfive,display-subsystem.yaml create mode 100644 Documentation/devicetree/bindings/display/starfive/starfive,dsi-encoder.yaml create mode 100644 Documentation/devicetree/bindings/display/starfive/starfive,jh7110-dc8200.yaml create mode 100644 Documentation/devicetree/bindings/display/starfive/starfive,jh7110-inno-hdmi.yaml create mode 100644 drivers/gpu/drm/verisilicon/Kconfig create mode 100644 drivers/gpu/drm/verisilicon/Makefile create mode 100644 drivers/gpu/drm/verisilicon/starfive_hdmi.c create mode 100644 drivers/gpu/drm/verisilicon/starfive_hdmi.h create mode 100644 drivers/gpu/drm/verisilicon/vs_crtc.c create mode 100644 drivers/gpu/drm/verisilicon/vs_crtc.h create mode 100644 drivers/gpu/drm/verisilicon/vs_dc.c create mode 100644 drivers/gpu/drm/verisilicon/vs_dc.h create mode 100644 drivers/gpu/drm/verisilicon/vs_dc_hw.c create mode 100644 drivers/gpu/drm/verisilicon/vs_dc_hw.h create mode 100644 drivers/gpu/drm/verisilicon/vs_drv.c create mode 100644 drivers/gpu/drm/verisilicon/vs_drv.h create mode 100644 drivers/gpu/drm/verisilicon/vs_modeset.c create mode 100644 drivers/gpu/drm/verisilicon/vs_modeset.h create mode 100644 drivers/gpu/drm/verisilicon/vs_plane.c create mode 100644 drivers/gpu/drm/verisilicon/vs_plane.h create mode 100644 drivers/gpu/drm/verisilicon/vs_simple_enc.c create mode 100644 drivers/gpu/drm/verisilicon/vs_simple_enc.h create mode 100644 drivers/gpu/drm/verisilicon/vs_type.h -- 2.34.1
RE: [PATCH v4 04/10] drm/vs: Add hardware funcs for vs.
Hi Dmitry: > -Original Message- > From: Dmitry Baryshkov > Sent: 2024年5月22日 4:51 > To: Keith Zhao > Cc: andrzej.ha...@intel.com; neil.armstr...@linaro.org; rf...@kernel.org; > laurent.pinch...@ideasonboard.com; jo...@kwiboo.se; > jernej.skra...@gmail.com; maarten.lankho...@linux.intel.com; > mrip...@kernel.org; tzimmerm...@suse.de; airl...@gmail.com; > dan...@ffwll.ch; r...@kernel.org; krzk...@kernel.org; conor...@kernel.org; > h...@rock-chips.com; he...@sntech.de; andy@rock-chips.com; Xingyu Wu > ; p.za...@pengutronix.de; Jack Zhu > ; Shengyang Chen > ; dri-devel@lists.freedesktop.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org > Subject: Re: [PATCH v4 04/10] drm/vs: Add hardware funcs for vs. > > On Tue, May 21, 2024 at 06:58:11PM +0800, keith wrote: > > add hardware base api for vs drm > > > Commit message is nearly missing. Please describe your hardware. Ok it will be modified next > > > > > Signed-off-by: keith > > Full name please > Ok it will be modified next > > --- > > MAINTAINERS|1 + > > drivers/gpu/drm/Kconfig|2 + > > drivers/gpu/drm/Makefile |1 + > > drivers/gpu/drm/verisilicon/Kconfig| 13 + > > drivers/gpu/drm/verisilicon/Makefile |5 + > > drivers/gpu/drm/verisilicon/vs_dc_hw.c | 1060 > > > drivers/gpu/drm/verisilicon/vs_dc_hw.h | 493 +++ > > drivers/gpu/drm/verisilicon/vs_type.h | 84 ++ > > 8 files changed, 1659 insertions(+) > > create mode 100644 drivers/gpu/drm/verisilicon/Kconfig > > create mode 100644 drivers/gpu/drm/verisilicon/Makefile > > create mode 100644 drivers/gpu/drm/verisilicon/vs_dc_hw.c > > create mode 100644 drivers/gpu/drm/verisilicon/vs_dc_hw.h > > create mode 100644 drivers/gpu/drm/verisilicon/vs_type.h > > > > diff --git a/MAINTAINERS b/MAINTAINERS > > index cf2d66f88a83..9cb376f76f74 100644 > > --- a/MAINTAINERS > > +++ b/MAINTAINERS > > @@ -7156,6 +7156,7 @@ T:git > https://gitlab.freedesktop.org/drm/misc/kernel.git > > F: > Documentation/devicetree/bindings/display/bridge/innosilicon,inno-hdmi.y > aml > > F: Documentation/devicetree/bindings/display/starfive/ > > F: drivers/gpu/drm/bridge/innosilicon/ > > +F: drivers/gpu/drm/verisilicon > > F: include/drm/bridge/inno_hdmi.h > > > > DRM DRIVER FOR SYNAPTICS R63353 PANELS > > diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig > > index 026444eeb5c6..5413d87ef1d6 100644 > > --- a/drivers/gpu/drm/Kconfig > > +++ b/drivers/gpu/drm/Kconfig > > @@ -423,6 +423,8 @@ source "drivers/gpu/drm/sprd/Kconfig" > > > > source "drivers/gpu/drm/imagination/Kconfig" > > > > +source "drivers/gpu/drm/verisilicon/Kconfig" > > + > > config DRM_HYPERV > > tristate "DRM Support for Hyper-V synthetic video device" > > depends on DRM && PCI && MMU && HYPERV > > diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile > > index f9ca4f8fa6c5..cb27092b1672 100644 > > --- a/drivers/gpu/drm/Makefile > > +++ b/drivers/gpu/drm/Makefile > > @@ -219,3 +219,4 @@ obj-y += solomon/ > > obj-$(CONFIG_DRM_SPRD) += sprd/ > > obj-$(CONFIG_DRM_LOONGSON) += loongson/ > > obj-$(CONFIG_DRM_POWERVR) += imagination/ > > +obj-$(CONFIG_DRM_VERISILICON_DC8200) += verisilicon/ > > diff --git a/drivers/gpu/drm/verisilicon/Kconfig > b/drivers/gpu/drm/verisilicon/Kconfig > > new file mode 100644 > > index ..2d733f93439e > > --- /dev/null > > +++ b/drivers/gpu/drm/verisilicon/Kconfig > > @@ -0,0 +1,13 @@ > > +# SPDX-License-Identifier: GPL-2.0 > > +config DRM_VERISILICON_DC8200 > > + tristate "DRM Support for VeriSilicon DC8200" > > + depends on DRM > > + select DRM_KMS_HELPER > > + select DRM_GEM_DMA_HELPER > > + select CMA > > + select DMA_CMA > > + help > > + Choose this option if you have a VeriSilicon DC8200 chipset. > > + This driver provides VeriSilicon kernel mode > > + setting and buffer management. It does not > > + provide 2D or 3D acceleration. > > diff --git a/drivers/gpu/drm/verisilicon/Makefile > b/drivers/gpu/drm/verisilicon/Makefile > > new file mode 100644 > > index ..7da54b259940 > > --- /dev/null > > +++ b/drivers/gpu/drm/verisilicon/Makefile > > @@ -0,0 +1,5 @@ > > +# SPDX-License-Identifier: GPL
RE: [PATCH v4 08/10] drm/vs: add vs drm master driver
Hi Dmitry: > -Original Message- > From: Dmitry Baryshkov > Sent: 2024年5月22日 5:14 > To: Keith Zhao > Cc: andrzej.ha...@intel.com; neil.armstr...@linaro.org; rf...@kernel.org; > laurent.pinch...@ideasonboard.com; jo...@kwiboo.se; > jernej.skra...@gmail.com; maarten.lankho...@linux.intel.com; > mrip...@kernel.org; tzimmerm...@suse.de; airl...@gmail.com; > dan...@ffwll.ch; r...@kernel.org; krzk...@kernel.org; conor...@kernel.org; > h...@rock-chips.com; he...@sntech.de; andy@rock-chips.com; Xingyu Wu > ; p.za...@pengutronix.de; Jack Zhu > ; Shengyang Chen > ; dri-devel@lists.freedesktop.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org > Subject: Re: [PATCH v4 08/10] drm/vs: add vs drm master driver > > On Tue, May 21, 2024 at 06:58:15PM +0800, keith wrote: > > Add vs DRM master driver for JH7110 SoC ADD DMA GEM driver > > > > Signed-off-by: keith > > --- > > drivers/gpu/drm/verisilicon/Makefile | 3 +- > > drivers/gpu/drm/verisilicon/vs_drv.c | 718 > > +++ > > 2 files changed, 720 insertions(+), 1 deletion(-) create mode 100644 > > drivers/gpu/drm/verisilicon/vs_drv.c > > > > diff --git a/drivers/gpu/drm/verisilicon/Makefile > > b/drivers/gpu/drm/verisilicon/Makefile > > index 26a43ca0fd36..88a07a308e31 100644 > > --- a/drivers/gpu/drm/verisilicon/Makefile > > +++ b/drivers/gpu/drm/verisilicon/Makefile > > @@ -3,6 +3,7 @@ > > vs_drm-objs := vs_dc_hw.o \ > > vs_modeset.o \ > > vs_plane.o \ > > - vs_crtc.o > > + vs_crtc.o \ > > + vs_drv.o > > > > obj-$(CONFIG_DRM_VERISILICON_DC8200) += vs_drm.o diff --git > > a/drivers/gpu/drm/verisilicon/vs_drv.c > > b/drivers/gpu/drm/verisilicon/vs_drv.c > > new file mode 100644 > > index ..c22fd2199fe2 > > --- /dev/null > > +++ b/drivers/gpu/drm/verisilicon/vs_drv.c > > @@ -0,0 +1,718 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +/* > > + * Copyright (C) 2023 VeriSilicon Holdings Co., Ltd. > > + */ > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#include "vs_drv.h" > > +#include "vs_crtc.h" > > +#include "vs_plane.h" > > +#include "vs_modeset.h" > > + > > +#define DRV_NAME "verisilicon" > > +#define DRV_DESC "Verisilicon DRM driver" > > +#define DRV_DATE "20230516" > > +#define DRV_MAJOR 1 > > +#define DRV_MINOR 0 > > + > > +#define FRAC_16_16(mult, div) (((mult) << 16) / (div)) > > + > > +static const u32 primary_overlay_format[] = { > > + DRM_FORMAT_RGB565, > > + DRM_FORMAT_BGR565, > > + DRM_FORMAT_XRGB, > > + DRM_FORMAT_XBGR, > > + DRM_FORMAT_RGBX, > > + DRM_FORMAT_BGRX, > > + DRM_FORMAT_ARGB, > > + DRM_FORMAT_ABGR, > > + DRM_FORMAT_RGBA, > > + DRM_FORMAT_BGRA, > > + DRM_FORMAT_XRGB, > > + DRM_FORMAT_XBGR, > > + DRM_FORMAT_RGBX, > > + DRM_FORMAT_BGRX, > > + DRM_FORMAT_ARGB, > > + DRM_FORMAT_ABGR, > > + DRM_FORMAT_RGBA, > > + DRM_FORMAT_BGRA, > > + DRM_FORMAT_XRGB1555, > > + DRM_FORMAT_XBGR1555, > > + DRM_FORMAT_RGBX5551, > > + DRM_FORMAT_BGRX5551, > > + DRM_FORMAT_ARGB1555, > > + DRM_FORMAT_ABGR1555, > > + DRM_FORMAT_RGBA5551, > > + DRM_FORMAT_BGRA5551, > > + DRM_FORMAT_ARGB2101010, > > + DRM_FORMAT_ABGR2101010, > > + DRM_FORMAT_RGBA1010102, > > + DRM_FORMAT_BGRA1010102, > > + DRM_FORMAT_YUYV, > > + DRM_FORMAT_YVYU, > > + DRM_FORMAT_UYVY, > > + DRM_FORMAT_VYUY, > > + DRM_FORMAT_YVU420, > > + DRM_FORMAT_YUV420, > > + DRM_FORMAT_NV12, > > + DRM_FORMAT_NV21, > > + DRM_FORMAT_NV16, > > + DRM_FORMAT_NV61, > > + DRM_FORMAT_P010, > > +}; > > + > > +static const u32 cursor_formats[] = { > > + DRM_FORMAT_ARGB > > +}; > > + > > +static const u64 format_modifier[] = { > > + DRM_FORMAT_MOD_LINEAR, > > + DRM_FORMAT_MOD_INVALID > > +}; > > + > > +static const u
RE: [PATCH v4 07/10] drm/vs: add ctrc fun
Hi Dmitry: > -Original Message- > From: Dmitry Baryshkov > Sent: 2024年5月22日 5:08 > To: Keith Zhao > Cc: andrzej.ha...@intel.com; neil.armstr...@linaro.org; rf...@kernel.org; > laurent.pinch...@ideasonboard.com; jo...@kwiboo.se; > jernej.skra...@gmail.com; maarten.lankho...@linux.intel.com; > mrip...@kernel.org; tzimmerm...@suse.de; airl...@gmail.com; > dan...@ffwll.ch; r...@kernel.org; krzk...@kernel.org; conor...@kernel.org; > h...@rock-chips.com; he...@sntech.de; andy@rock-chips.com; Xingyu Wu > ; p.za...@pengutronix.de; Jack Zhu > ; Shengyang Chen > ; dri-devel@lists.freedesktop.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org > Subject: Re: [PATCH v4 07/10] drm/vs: add ctrc fun > > On Tue, May 21, 2024 at 06:58:14PM +0800, keith wrote: > > add crtc funs and helper funs > > > > Signed-off-by: keith > > --- > > drivers/gpu/drm/verisilicon/Makefile | 3 +- > > drivers/gpu/drm/verisilicon/vs_crtc.c | 241 > > ++ drivers/gpu/drm/verisilicon/vs_crtc.h | > > 17 ++ > > 3 files changed, 260 insertions(+), 1 deletion(-) create mode 100644 > > drivers/gpu/drm/verisilicon/vs_crtc.c > > create mode 100644 drivers/gpu/drm/verisilicon/vs_crtc.h > > > > diff --git a/drivers/gpu/drm/verisilicon/Makefile > > b/drivers/gpu/drm/verisilicon/Makefile > > index 1c593b943261..26a43ca0fd36 100644 > > --- a/drivers/gpu/drm/verisilicon/Makefile > > +++ b/drivers/gpu/drm/verisilicon/Makefile > > @@ -2,6 +2,7 @@ > > > > vs_drm-objs := vs_dc_hw.o \ > > vs_modeset.o \ > > - vs_plane.o > > + vs_plane.o \ > > + vs_crtc.o > > > > obj-$(CONFIG_DRM_VERISILICON_DC8200) += vs_drm.o diff --git > > a/drivers/gpu/drm/verisilicon/vs_crtc.c > > b/drivers/gpu/drm/verisilicon/vs_crtc.c > > new file mode 100644 > > index ..ea7640a63c28 > > --- /dev/null > > +++ b/drivers/gpu/drm/verisilicon/vs_crtc.c > > @@ -0,0 +1,241 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +/* > > + * Copyright (C) 2023 VeriSilicon Holdings Co., Ltd. > > + * > > + */ > > +#include > > +#include > > +#include > > +#include #include > > + > > +#include "vs_crtc.h" > > + > > +static void vs_crtc_atomic_destroy_state(struct drm_crtc *crtc, > > +struct drm_crtc_state *state) > > +{ > > + __drm_atomic_helper_crtc_destroy_state(state); > > + kfree(to_vs_crtc_state(state)); > > +} > > + > > +static void vs_crtc_reset(struct drm_crtc *crtc) { > > + struct vs_crtc_state *state; > > + > > + if (crtc->state) > > + vs_crtc_atomic_destroy_state(crtc, crtc->state); > > + > > + state = kzalloc(sizeof(*state), GFP_KERNEL); > > + if (!state) > > + return; > > + > > + __drm_atomic_helper_crtc_reset(crtc, &state->base); } > > + > > +static struct drm_crtc_state * > > +vs_crtc_atomic_duplicate_state(struct drm_crtc *crtc) { > > + struct vs_crtc_state *old_state; > > + struct vs_crtc_state *state; > > + > > + if (!crtc->state) > > + return NULL; > > + > > + old_state = to_vs_crtc_state(crtc->state); > > + > > + state = kmemdup(old_state, sizeof(*old_state), GFP_KERNEL); > > + if (!state) > > + return NULL; > > + > > + __drm_atomic_helper_crtc_duplicate_state(crtc, &state->base); > > + > > + return &state->base; > > +} > > + > > +static int vs_crtc_enable_vblank(struct drm_crtc *crtc) { > > + struct vs_drm_device *priv = to_vs_drm_private(crtc->dev); > > + struct vs_dc *dc = &priv->dc; > > + > > + dc_hw_enable_interrupt(&dc->hw); > > + > > + return 0; > > +} > > + > > +static void vs_crtc_disable_vblank(struct drm_crtc *crtc) { > > + struct vs_drm_device *priv = to_vs_drm_private(crtc->dev); > > + struct vs_dc *dc = &priv->dc; > > + > > + dc_hw_disable_interrupt(&dc->hw); > > +} > > + > > +static const struct drm_crtc_funcs vs_crtc_funcs = { > > + .set_config = drm_atomic_helper_set_config, > > + .page_flip = drm_atomic_helper_page_flip, > > + .reset = vs_crtc_reset, > > + .atomic_duplicate_state = vs_crtc_atomic_duplicate_state, > > + .atomic_destroy_state = vs_crtc_atomic_destroy_state
RE: [PATCH v4 05/10] drm/vs: add vs mode config init
Hi Dmitry: > -Original Message- > From: Dmitry Baryshkov > Sent: 2024年5月22日 4:53 > To: Keith Zhao > Cc: andrzej.ha...@intel.com; neil.armstr...@linaro.org; rf...@kernel.org; > laurent.pinch...@ideasonboard.com; jo...@kwiboo.se; > jernej.skra...@gmail.com; maarten.lankho...@linux.intel.com; > mrip...@kernel.org; tzimmerm...@suse.de; airl...@gmail.com; > dan...@ffwll.ch; r...@kernel.org; krzk...@kernel.org; conor...@kernel.org; > h...@rock-chips.com; he...@sntech.de; andy@rock-chips.com; Xingyu Wu > ; p.za...@pengutronix.de; Jack Zhu > ; Shengyang Chen > ; dri-devel@lists.freedesktop.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org > Subject: Re: [PATCH v4 05/10] drm/vs: add vs mode config init > > On Tue, May 21, 2024 at 06:58:12PM +0800, keith wrote: > > add vs mode config base api > > Commit message? Please describe e.g. why are you using > drm_atomic_helper_commit_tail_rpm() instead of > drm_atomic_helper_commit_tail(). > > > > > Signed-off-by: keith > > Name This can be modified. > > > --- > > drivers/gpu/drm/verisilicon/Makefile | 3 +- > > drivers/gpu/drm/verisilicon/vs_modeset.c | 36 > > drivers/gpu/drm/verisilicon/vs_modeset.h | > > 10 +++ > > 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 > > drivers/gpu/drm/verisilicon/vs_modeset.c > > create mode 100644 drivers/gpu/drm/verisilicon/vs_modeset.h > > > > diff --git a/drivers/gpu/drm/verisilicon/Makefile > > b/drivers/gpu/drm/verisilicon/Makefile > > index 7da54b259940..536091f37378 100644 > > --- a/drivers/gpu/drm/verisilicon/Makefile > > +++ b/drivers/gpu/drm/verisilicon/Makefile > > @@ -1,5 +1,6 @@ > > # SPDX-License-Identifier: GPL-2.0 > > > > -vs_drm-objs := vs_dc_hw.o > > +vs_drm-objs := vs_dc_hw.o \ > > + vs_modeset.o > > > > obj-$(CONFIG_DRM_VERISILICON_DC8200) += vs_drm.o diff --git > > a/drivers/gpu/drm/verisilicon/vs_modeset.c > > b/drivers/gpu/drm/verisilicon/vs_modeset.c > > new file mode 100644 > > index ..c71fe0d32504 > > --- /dev/null > > +++ b/drivers/gpu/drm/verisilicon/vs_modeset.c > > @@ -0,0 +1,36 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +/* > > + * Copyright (C) 2023 VeriSilicon Holdings Co., Ltd. > > + */ > > +#include > > I don't see anything concerning damage helpers being used here. > Yes , it should use drm_atomic_helper.h instead of drm_damage_helper.h > > +#include > > +#include > > + > > +#include "vs_modeset.h" > > + > > +static const struct drm_mode_config_funcs vs_mode_config_funcs = { > > + .fb_create = drm_gem_fb_create, > > + .atomic_check= drm_atomic_helper_check, > > + .atomic_commit = drm_atomic_helper_commit, > > +}; > > + > > +static struct drm_mode_config_helper_funcs vs_mode_config_helpers = { > > + .atomic_commit_tail = drm_atomic_helper_commit_tail_rpm, > > +}; > > + > > +void vs_mode_config_init(struct drm_device *dev) { > > + int ret; > > + > > + ret = drmm_mode_config_init(dev); > > + if (ret) > > + return; > > + > > + dev->mode_config.min_width = 0; > > + dev->mode_config.min_height = 0; > > + dev->mode_config.max_width = 4096; > > + dev->mode_config.max_height = 4096; > > + > > + dev->mode_config.funcs = &vs_mode_config_funcs; > > + dev->mode_config.helper_private = &vs_mode_config_helpers; } > > diff --git a/drivers/gpu/drm/verisilicon/vs_modeset.h > > b/drivers/gpu/drm/verisilicon/vs_modeset.h > > new file mode 100644 > > index ..bd04f81d2ad2 > > --- /dev/null > > +++ b/drivers/gpu/drm/verisilicon/vs_modeset.h > > @@ -0,0 +1,10 @@ > > +/* SPDX-License-Identifier: GPL-2.0 */ > > +/* > > + * Copyright (C) 2020 VeriSilicon Holdings Co., Ltd. > > + */ > > + > > +#ifndef __VS_MODESET_H__ > > +#define __VS_MODESET_H__ > > + > > +void vs_mode_config_init(struct drm_device *dev); #endif /* > > +__VS_FB_H__ */ > > -- > > 2.27.0 > > > > -- > With best wishes > Dmitry
RE: [PATCH v4 10/10] drm/vs: add simple dsi encoder
Hi Dmitry: > -Original Message- > From: Dmitry Baryshkov > Sent: 2024年5月21日 23:25 > To: Keith Zhao > Cc: andrzej.ha...@intel.com; neil.armstr...@linaro.org; rf...@kernel.org; > laurent.pinch...@ideasonboard.com; jo...@kwiboo.se; > jernej.skra...@gmail.com; maarten.lankho...@linux.intel.com; > mrip...@kernel.org; tzimmerm...@suse.de; airl...@gmail.com; > dan...@ffwll.ch; r...@kernel.org; krzk...@kernel.org; conor...@kernel.org; > h...@rock-chips.com; he...@sntech.de; andy@rock-chips.com; Xingyu Wu > ; p.za...@pengutronix.de; Jack Zhu > ; Shengyang Chen > ; dri-devel@lists.freedesktop.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org > Subject: Re: [PATCH v4 10/10] drm/vs: add simple dsi encoder > > On Tue, May 21, 2024 at 06:58:17PM +0800, keith wrote: > > add encoder to match cdns dsi driver > > > > Signed-off-by: keith > > Please fix your git configuration to include your full name into the S-o-B and > Author fields. Ok ,will fix it > > > --- > > drivers/gpu/drm/verisilicon/Makefile| 3 +- > > drivers/gpu/drm/verisilicon/vs_drv.c| 1 + > > drivers/gpu/drm/verisilicon/vs_drv.h| 1 + > > drivers/gpu/drm/verisilicon/vs_simple_enc.c | 190 > > drivers/gpu/drm/verisilicon/vs_simple_enc.h | > > 25 +++ > > 5 files changed, 219 insertions(+), 1 deletion(-) create mode 100644 > > drivers/gpu/drm/verisilicon/vs_simple_enc.c > > create mode 100644 drivers/gpu/drm/verisilicon/vs_simple_enc.h > > > > diff --git a/drivers/gpu/drm/verisilicon/Makefile > > b/drivers/gpu/drm/verisilicon/Makefile > > index 2d02b4a3a567..c35ba9bd6f81 100644 > > --- a/drivers/gpu/drm/verisilicon/Makefile > > +++ b/drivers/gpu/drm/verisilicon/Makefile > > @@ -4,7 +4,8 @@ vs_drm-objs := vs_dc_hw.o \ > > vs_modeset.o \ > > vs_plane.o \ > > vs_crtc.o \ > > - vs_drv.o > > + vs_drv.o \ > > + vs_simple_enc.o > > > > vs_drm-$(CONFIG_DRM_INNO_STARFIVE_HDMI) += inno_hdmi-starfive.o > > obj-$(CONFIG_DRM_VERISILICON_DC8200) += vs_drm.o diff --git > > a/drivers/gpu/drm/verisilicon/vs_drv.c > > b/drivers/gpu/drm/verisilicon/vs_drv.c > > index 6f04102b05b3..2748d48f2c7e 100644 > > --- a/drivers/gpu/drm/verisilicon/vs_drv.c > > +++ b/drivers/gpu/drm/verisilicon/vs_drv.c > > @@ -612,6 +612,7 @@ static struct platform_driver *drm_sub_drivers[] = > > { #ifdef CONFIG_DRM_INNO_STARFIVE_HDMI > > &starfive_hdmi_driver, > > #endif > > + &simple_encoder_driver, > > }; > > > > static struct component_match *vs_add_external_components(struct > > device *dev) diff --git a/drivers/gpu/drm/verisilicon/vs_drv.h > > b/drivers/gpu/drm/verisilicon/vs_drv.h > > index c3c08ed5f8ac..f3f0f170777d 100644 > > --- a/drivers/gpu/drm/verisilicon/vs_drv.h > > +++ b/drivers/gpu/drm/verisilicon/vs_drv.h > > @@ -17,6 +17,7 @@ > > #include > > > > #include "vs_dc_hw.h" > > +#include "vs_simple_enc.h" > > > > /*@pitch_alignment: buffer pitch alignment required by sub-devices.*/ > > struct vs_drm_device { diff --git > > a/drivers/gpu/drm/verisilicon/vs_simple_enc.c > > b/drivers/gpu/drm/verisilicon/vs_simple_enc.c > > new file mode 100644 > > index ..d0b1755d77d2 > > --- /dev/null > > +++ b/drivers/gpu/drm/verisilicon/vs_simple_enc.c > > @@ -0,0 +1,190 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +/* > > + * Copyright (C) 2020 VeriSilicon Holdings Co., Ltd. > > Now it is 2024, so the copyright should probably cover the range. Ok ,will fix it > > > + */ > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#include > > +#include > > +#include > > +#include > > + > > +#include "vs_crtc.h" > > +#include "vs_simple_enc.h" > > + > > +static const struct simple_encoder_priv dsi_priv = { > > + .encoder_type = DRM_MODE_ENCODER_DSI > > So, is it 'simple' aka something generic or DSI? In the latter case, please > rename > it accordingly. Ok will done > > > +}; > > + > > +static inline struct vs_simple_encoder *to_simple_encoder(struct > > +drm_encoder *enc) { > > + return container_of(enc, struct vs_simple_encoder, encoder); } > > + > > +static int encoder_parse_dt(struct device *dev) { > > + st
RE: [PATCH v4 06/10] drm/vs: add vs plane api
Hi Dmitry: > -Original Message- > From: Dmitry Baryshkov > Sent: 2024年5月22日 5:06 > To: Keith Zhao > Cc: andrzej.ha...@intel.com; neil.armstr...@linaro.org; rf...@kernel.org; > laurent.pinch...@ideasonboard.com; jo...@kwiboo.se; > jernej.skra...@gmail.com; maarten.lankho...@linux.intel.com; > mrip...@kernel.org; tzimmerm...@suse.de; airl...@gmail.com; > dan...@ffwll.ch; r...@kernel.org; krzk...@kernel.org; conor...@kernel.org; > h...@rock-chips.com; he...@sntech.de; andy@rock-chips.com; Xingyu Wu > ; p.za...@pengutronix.de; Jack Zhu > ; Shengyang Chen > ; dri-devel@lists.freedesktop.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org > Subject: Re: [PATCH v4 06/10] drm/vs: add vs plane api > > On Tue, May 21, 2024 at 06:58:13PM +0800, keith wrote: > > add plane funs and helper funs > > add vs drm common struct and funs > > > > Signed-off-by: keith > > --- > > drivers/gpu/drm/verisilicon/Makefile | 3 +- > > drivers/gpu/drm/verisilicon/vs_drv.h | 93 + > > drivers/gpu/drm/verisilicon/vs_plane.c | 487 > > + drivers/gpu/drm/verisilicon/vs_plane.h | > > 26 ++ > > 4 files changed, 608 insertions(+), 1 deletion(-) create mode 100644 > > drivers/gpu/drm/verisilicon/vs_drv.h > > create mode 100644 drivers/gpu/drm/verisilicon/vs_plane.c > > create mode 100644 drivers/gpu/drm/verisilicon/vs_plane.h > > > > diff --git a/drivers/gpu/drm/verisilicon/Makefile > > b/drivers/gpu/drm/verisilicon/Makefile > > index 536091f37378..1c593b943261 100644 > > --- a/drivers/gpu/drm/verisilicon/Makefile > > +++ b/drivers/gpu/drm/verisilicon/Makefile > > @@ -1,6 +1,7 @@ > > # SPDX-License-Identifier: GPL-2.0 > > > > vs_drm-objs := vs_dc_hw.o \ > > - vs_modeset.o > > + vs_modeset.o \ > > + vs_plane.o > > > > obj-$(CONFIG_DRM_VERISILICON_DC8200) += vs_drm.o diff --git > > a/drivers/gpu/drm/verisilicon/vs_drv.h > > b/drivers/gpu/drm/verisilicon/vs_drv.h > > new file mode 100644 > > index ..d9f6efa7c8f9 > > --- /dev/null > > +++ b/drivers/gpu/drm/verisilicon/vs_drv.h > > @@ -0,0 +1,93 @@ > > +/* SPDX-License-Identifier: GPL-2.0 */ > > +/* > > + * Copyright (C) 2023 VeriSilicon Holdings Co., Ltd. > > + */ > > + > > +#ifndef __VS_DRV_H__ > > +#define __VS_DRV_H__ > > + > > +#include > > +#include > > +#include > > +#include > > + > > +#include > > +#include > > +#include > > +#include > > + > > +#include "vs_dc_hw.h" > > + > > +/*@pitch_alignment: buffer pitch alignment required by sub-devices.*/ > > Is that all the docs you want to add? It should delete the redundant parts which is unused, To make this patch clearer to review > > > +struct vs_drm_device { > > + struct drm_device base; > > + unsigned int pitch_alignment; > > + /* clocks */ > > + unsigned int clk_count; > > + struct clk_bulk_data*clks; > > + struct reset_control*rsts; > > + struct vs_dc dc; > > + int irq; > > As usual, please drop unused fields and add them when required. In principle, I try to split the patch independently according to this. In fact, there is still a lot of room for optimization The subsequent patches will maintain independence and remove redundant parts for decoupling > > > +}; > > + > > +static inline struct vs_drm_device * > > +to_vs_drm_private(const struct drm_device *dev) { > > + return container_of(dev, struct vs_drm_device, base); } > > + > > +struct vs_crtc_state { > > + struct drm_crtc_state base; > > + > > + u32 output_fmt; > > + u8 encoder_type; > > + u8 bpp; > > +}; > > Not used here, drop. > > > + > > +struct vs_crtc { > > + struct drm_crtc base; > > + struct device *dev; > > +}; > > > > + > > +static inline u8 to_vs_display_id(struct vs_dc *dc, struct drm_crtc > > +*crtc) { > > + u8 panel_num = dc->hw.info->panel_num; > > + u32 index = drm_crtc_index(crtc); > > + int i; > > + > > + for (i = 0; i < panel_num; i++) { > > + if (index == dc->crtc[i]->base.index) > > + return i; > > + } > > + > > + return 0; > > +} > > + > > +static inline struct vs_crtc_state * > > +to_vs_crtc_state(struct drm_crtc_state *state) { > > + return container_of(state, struct vs_crtc_state, base); }
RE: [PATCH v4 03/10] drm/rockchip:hdmi: migrate to use inno-hdmi bridge driver
Hi Maxime: > -Original Message- > From: Maxime Ripard > Sent: 2024年5月22日 15:25 > To: Keith Zhao > Cc: andrzej.ha...@intel.com; neil.armstr...@linaro.org; rf...@kernel.org; > laurent.pinch...@ideasonboard.com; jo...@kwiboo.se; > jernej.skra...@gmail.com; maarten.lankho...@linux.intel.com; > tzimmerm...@suse.de; airl...@gmail.com; dan...@ffwll.ch; r...@kernel.org; > krzk...@kernel.org; conor...@kernel.org; h...@rock-chips.com; > he...@sntech.de; andy@rock-chips.com; Xingyu Wu > ; p.za...@pengutronix.de; Jack Zhu > ; Shengyang Chen > ; dri-devel@lists.freedesktop.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org > Subject: Re: [PATCH v4 03/10] drm/rockchip:hdmi: migrate to use inno-hdmi > bridge driver > > Hi, > > On Tue, May 21, 2024 at 06:58:10PM GMT, keith wrote: > > Add the ROCKCHIP inno hdmi driver that uses the Inno DesignWare HDMI > > TX bridge and remove the old separate one. > > > > Signed-off-by: keith > > --- > > drivers/gpu/drm/rockchip/Kconfig |1 + > > drivers/gpu/drm/rockchip/Makefile |2 +- > > drivers/gpu/drm/rockchip/inno_hdmi-rockchip.c | 517 > > .../{inno_hdmi.h => inno_hdmi-rockchip.h} | 45 - > > drivers/gpu/drm/rockchip/inno_hdmi.c | 1073 - > > 5 files changed, 519 insertions(+), 1119 deletions(-) create mode > > 100644 drivers/gpu/drm/rockchip/inno_hdmi-rockchip.c > > rename drivers/gpu/drm/rockchip/{inno_hdmi.h => inno_hdmi-rockchip.h} > > (85%) delete mode 100644 drivers/gpu/drm/rockchip/inno_hdmi.c > > > > diff --git a/drivers/gpu/drm/rockchip/Kconfig > > b/drivers/gpu/drm/rockchip/Kconfig > > index 1bf3e2829cd0..cc6cfd5a30d6 100644 > > --- a/drivers/gpu/drm/rockchip/Kconfig > > +++ b/drivers/gpu/drm/rockchip/Kconfig > > @@ -74,6 +74,7 @@ config ROCKCHIP_DW_MIPI_DSI > > > > config ROCKCHIP_INNO_HDMI > > bool "Rockchip specific extensions for Innosilicon HDMI" > > + select DRM_INNO_HDMI > > help > > This selects support for Rockchip SoC specific extensions > > for the Innosilicon HDMI driver. If you want to enable diff --git > > a/drivers/gpu/drm/rockchip/Makefile > > b/drivers/gpu/drm/rockchip/Makefile > > index 3ff7b21c0414..4b2d0cba8db3 100644 > > --- a/drivers/gpu/drm/rockchip/Makefile > > +++ b/drivers/gpu/drm/rockchip/Makefile > > @@ -12,7 +12,7 @@ rockchipdrm-$(CONFIG_ROCKCHIP_ANALOGIX_DP) += > > analogix_dp-rockchip.o > > rockchipdrm-$(CONFIG_ROCKCHIP_CDN_DP) += cdn-dp-core.o cdn-dp-reg.o > > rockchipdrm-$(CONFIG_ROCKCHIP_DW_HDMI) += dw_hdmi-rockchip.o > > rockchipdrm-$(CONFIG_ROCKCHIP_DW_MIPI_DSI) += > dw-mipi-dsi-rockchip.o > > -rockchipdrm-$(CONFIG_ROCKCHIP_INNO_HDMI) += inno_hdmi.o > > +rockchipdrm-$(CONFIG_ROCKCHIP_INNO_HDMI) += inno_hdmi-rockchip.o > > rockchipdrm-$(CONFIG_ROCKCHIP_LVDS) += rockchip_lvds.o > > rockchipdrm-$(CONFIG_ROCKCHIP_RGB) += rockchip_rgb.o > > rockchipdrm-$(CONFIG_ROCKCHIP_RK3066_HDMI) += rk3066_hdmi.o diff > > --git a/drivers/gpu/drm/rockchip/inno_hdmi-rockchip.c > > b/drivers/gpu/drm/rockchip/inno_hdmi-rockchip.c > > new file mode 100644 > > index ..69d0e913e13b > > --- /dev/null > > +++ b/drivers/gpu/drm/rockchip/inno_hdmi-rockchip.c > > @@ -0,0 +1,517 @@ > > +// SPDX-License-Identifier: GPL-2.0-only > > +/* > > + * Copyright (C) Fuzhou Rockchip Electronics Co.Ltd > > + *Zheng Yang > > + *Yakir Yang > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#include "rockchip_drm_drv.h" > > + > > +#include "inno_hdmi-rockchip.h" > > + > > +#define INNO_HDMI_MIN_TMDS_CLOCK 2500U > > + > > +struct rk_inno_hdmi { > > + struct rockchip_encoder encoder; > > + struct inno_hdmi inno_hdmi; > > + struct clk *pclk; > > + struct clk *refclk; > > +}; > > + > > +static struct inno_hdmi *rk_encoder_to_inno_hdmi(struct drm_encoder > > +*encoder) { > > + struct rockchip_encoder *rkencoder = to_rockchip_encoder(encoder); > > + struct rk_inno_hdmi *rk_hdmi = container_of(rkencoder, struct > > +rk_inno_hdmi, encoder); > > + > > + return &rk_hdmi->inno_hdmi; > >
RE: [PATCH v4 04/10] drm/vs: Add hardware funcs for vs.
> -Original Message- > From: Dmitry Baryshkov > Sent: 2024年6月24日 4:51 > To: Keith Zhao > Cc: andrzej.ha...@intel.com; neil.armstr...@linaro.org; rf...@kernel.org; > laurent.pinch...@ideasonboard.com; jo...@kwiboo.se; > jernej.skra...@gmail.com; maarten.lankho...@linux.intel.com; > mrip...@kernel.org; tzimmerm...@suse.de; airl...@gmail.com; > dan...@ffwll.ch; r...@kernel.org; krzk...@kernel.org; conor...@kernel.org; > h...@rock-chips.com; he...@sntech.de; andy@rock-chips.com; Xingyu Wu > ; p.za...@pengutronix.de; Jack Zhu > ; Shengyang Chen > ; dri-devel@lists.freedesktop.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org > Subject: Re: [PATCH v4 04/10] drm/vs: Add hardware funcs for vs. > > Hi Keith, > > On Sun, Jun 23, 2024 at 07:16:47AM GMT, Keith Zhao wrote: > > > On Tue, May 21, 2024 at 06:58:11PM +0800, keith wrote: > > > > +} > > > > + > > > > +static inline void dc_set_clear(struct dc_hw *hw, u32 reg, u32 > > > > +set, u32 clear) { > > > > + u32 value = dc_read(hw, reg); > > > > + > > > > + value &= ~clear; > > > > + value |= set; > > > > + dc_write(hw, reg, value); > > > > > > regmap_update_bits? > > > > regmap_update_bits follows 4 steps: > > > > 1、ret = _regmap_read(map, reg, &orig); . > > > > 2、tmp = orig & ~mask; > > 3、tmp |= val & mask; > > .. > > 4、ret = _regmap_write(map, reg, tmp); > > If the value out of mask range > > It will just clear the mask bir > > > > dc_set_clear will do clear and set without limit. > > > > Maybe the name should be dc_clear_set > > This is not really better. regmap_update_bits() has clear semantics of > updating a > value in the field that is defined by a mask. You function is just clearing > some bits > and setting other bits. It's not obvious whether it is a mask and value, > several > concurrent flags or something else. > > Even if you are not going to switch to regmaps (you don't have to), please use > mask & value instead. > Ok got it > > } > > > > +static void load_rgb_to_yuv(struct dc_hw *hw, u32 offset, s16 > > > > +*table) > > > > > > Is there any reason why load_rgb_to_yuv differs from two other > > > functions? > > > > > load_rgb_to_yuv matches crtcs > > > > load_yuv_to_rgb matches planes > > load_rgb_to_rgb matches planes > > Then these functins should have that reflected in their names (and also > documented, why). If the CSC programming interface is similar, please split > the > implementation to have common code and different data to be used for > programming. > Ok got it > > the coefficient(table) is diff between load_rgb_to_yuv and > > load_yuv_to_rgb > > > > > +void plane_hw_update_scale(struct vs_dc *dc, struct drm_rect > > > > +*src, struct > > > drm_rect *dst, > > > > + u8 id, u8 display_id, unsigned int > > > > rotation); void > > > > +plane_hw_update_blend(struct vs_dc *dc, u16 alpha, u16 > > > pixel_blend_mode, > > > > + u8 id, u8 display_id); > > > > > > Could you please settle on a single prefix for all your function names? > > > Ideally it should be close to the driver name. It's hard to > > > understand that the function comes from the verisilicon driver if > > > its name starts from dc_ or especially with plane_. > > Yes starting with plane_ is not a good idea ,i will add vs_ _ , > > thanks > > > > > > I'd strongly suggest to stop defining anything outside of the > > > selected > > I don't quite understand what "the selected" means, I hope you can > > fill in some specific details about it Thanks > > "the selected vs_ namespace". So prefix all function names and all structures > with vs_ Ok, got it. > > > -- > With best wishes > Dmitry
RE: [PATCH v4 10/10] drm/vs: add simple dsi encoder
> -Original Message- > From: Dmitry Baryshkov > Sent: 2024年6月24日 5:11 > To: Keith Zhao > Cc: andrzej.ha...@intel.com; neil.armstr...@linaro.org; rf...@kernel.org; > laurent.pinch...@ideasonboard.com; jo...@kwiboo.se; > jernej.skra...@gmail.com; maarten.lankho...@linux.intel.com; > mrip...@kernel.org; tzimmerm...@suse.de; airl...@gmail.com; > dan...@ffwll.ch; r...@kernel.org; krzk...@kernel.org; conor...@kernel.org; > h...@rock-chips.com; he...@sntech.de; andy@rock-chips.com; Xingyu Wu > ; p.za...@pengutronix.de; Jack Zhu > ; Shengyang Chen > ; dri-devel@lists.freedesktop.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org > Subject: Re: [PATCH v4 10/10] drm/vs: add simple dsi encoder > > On Sun, Jun 23, 2024 at 07:17:09AM GMT, Keith Zhao wrote: > > Hi Dmitry: > > > > > On Tue, May 21, 2024 at 06:58:17PM +0800, keith wrote: > > > > > + > > > > "starfive,syscon", > > > > + 2, > > > > args); > > > > + > > > > + if (IS_ERR(simple->dss_regmap)) { > > > > + return dev_err_probe(dev, PTR_ERR(simple->dss_regmap), > > > > +"getting the regmap failed\n"); > > > > + } > > > > + > > > > + simple->offset = args[0]; > > > > + simple->mask = args[1]; > > > > > > Is the value that you've read platform dependent or use case dependent? > > > What is the actual value being written? Why are you using syscon for it? > > > > The syscon is used to select crtcs binded with encoder, If this > > encoder binds to crtc0 , set the syscon reg bit0 = 1 If this encoder > > binds to crtc1 , set the syscon reg bit1 = 1 (0x2) Maybe I can do this > > by the possible_crtc instead of using args from dts > > If this is a constant between your platforms, it should not be a part of DT. > > > > > > > > > > > > + > > > > + return 0; > > > > +} > > > > + > > > > +static void vs_encoder_atomic_enable(struct drm_encoder *encoder, > > > > +struct drm_atomic_state *state) { > > > > + struct vs_simple_encoder *simple = to_simple_encoder(encoder); > > > > + > > > > + regmap_update_bits(simple->dss_regmap, simple->offset, > > > > +simple->mask, > > > > +simple->mask); > > > > > > > > > A purist in me would ask to have separate mask and value to write. > > Understand , will avoid this action > > > > > > > +} > > > > > > Is it necessary to clear those bits when stopping the stream? > > No need to do this , if clear those bits , the encoder will point to a > > unknown crtc > > what are the consequences? Is it desirable or not? There are two crtcs. Each display terminal encoder can combine any crtc, depending on the value of possible crtc. When the bit is 0, it means that the encoder matches crtc0. When the bit is 1, it means that the encoder matches crtc1. The possible crtc of this encoder is 2 , the reg bit is 1. When the video stream is stopped, if the bit is cleared, the result is that the encoder hardware points to crtc0, and the encoder points to crtc1 based on the drm framework(because the possible crtc no change). > > -- > With best wishes > Dmitry
RE: [PATCH v4 08/10] drm/vs: add vs drm master driver
> -Original Message- > From: Dmitry Baryshkov > Sent: 2024年6月24日 5:08 > To: Keith Zhao > Cc: andrzej.ha...@intel.com; neil.armstr...@linaro.org; rf...@kernel.org; > laurent.pinch...@ideasonboard.com; jo...@kwiboo.se; > jernej.skra...@gmail.com; maarten.lankho...@linux.intel.com; > mrip...@kernel.org; tzimmerm...@suse.de; airl...@gmail.com; > dan...@ffwll.ch; r...@kernel.org; krzk...@kernel.org; conor...@kernel.org; > h...@rock-chips.com; he...@sntech.de; andy@rock-chips.com; Xingyu Wu > ; p.za...@pengutronix.de; Jack Zhu > ; Shengyang Chen > ; dri-devel@lists.freedesktop.org; > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org > Subject: Re: [PATCH v4 08/10] drm/vs: add vs drm master driver > > On Sun, Jun 23, 2024 at 07:16:57AM GMT, Keith Zhao wrote: > > > On Tue, May 21, 2024 at 06:58:15PM +0800, keith wrote: > > > > Add vs DRM master driver for JH7110 SoC ADD DMA GEM driver > > > > > > > > Signed-off-by: keith > > > > --- > > > > drivers/gpu/drm/verisilicon/Makefile | 3 +- > > > > drivers/gpu/drm/verisilicon/vs_drv.c | 718 > > > > +++ > > > > 2 files changed, 720 insertions(+), 1 deletion(-) create mode > > > > 100644 drivers/gpu/drm/verisilicon/vs_drv.c > > > > > > > > BIT(DRM_COLOR_YCBCR_BT2020), > > > > + .zpos = 0, > > > > > > How are these zpos related to the zpos from drm_plane_state? > > Zpos was added to drm_plane_state by calling > > drm_plane_create_zpos_property funs, > > > > vs_plane_primary_create > > --> drm_plane_create_zpos_property(..vs_plane_primary_info-> > > --> zpos ) > > Yes. But why do you need zpos here? Especially if it's set to 0. if any plane has the zpos attribute (whether variable or immutable), then all planes should have the zpos attribute to ensure consistent stacking order and behavior. Here is the initial value of zpos property Usually min can be set to 0 and I set the zpos of primary plane to 0.. > > > > > > > > + > > > > + drm_dev->mode_config.min_width = min_width; > > > > + drm_dev->mode_config.min_height = min_heigth; > > > > + drm_dev->mode_config.max_width = max_width; > > > > + drm_dev->mode_config.max_height = max_height; > > > > > > I thought that I saw mode_config.min/max being initialized. > > Yes the mode_config.min/max has been initialized, > > This place is doing an update according to detail info. > > Then please drop previous initialisation. While looking at the code it's > impossible to understand which one is correct. Ok got it. > > > > > > + > > > > +static struct component_match *vs_add_external_components(struct > > > > +device *dev) { > > > > + struct component_match *match = NULL; > > > > + int i; > > > > + > > > > + for (i = 0; i < ARRAY_SIZE(drm_sub_drivers); ++i) { > > > > + struct platform_driver *drv = drm_sub_drivers[i]; > > > > + struct device *p = NULL, *d; > > > > + > > > > + while ((d = platform_find_device_by_driver(p, > > > > &drv->driver))) { > > > > + put_device(p); > > > > + > > > > + drm_of_component_match_add(dev, &match, > > > component_compare_of, > > > > + d->of_node); > > > > + p = d; > > > > + } > > > > + put_device(p); > > > > > > What about just going through the graph connections instead and adding > them? > > > > The purpose of using components is to create encoder and connector to the > drm subsystem by calling component_bind_all > > > > graph connection needs to be based on whether there is a bridge at present. > > If the bridge has been added, it can be obtained through drm_of_get_bridge > > Create a connector based on the obtained bridge and then attach the > connector to the encoder. > > Then do drm_dev_register. > > > > I don't know if my understanding is consistent with yours. Please help > > confirm > it. > > Thanks > > Your code is looping over the subdrivers, locating devices and then > adding them as components. Can you instead use device nodes which are > connecte
Re: [PATCH v1 0/2] Add waveshare 7inch touchscreen panel support
On 2023/11/25 0:04, Dave Stevenson wrote: > On Fri, 24 Nov 2023 at 15:00, Stefan Wahren wrote: >> >> Hi Shengyang, >> >> [fix address of Emma] > > Not merged to master yet, but Emma has stepped back from maintenance. > https://lists.freedesktop.org/archives/dri-devel/2023-October/428829.html > Dropped from the cc. > >> Am 24.11.23 um 11:44 schrieb Shengyang Chen: >> > This patchset adds waveshare 7inch touchscreen panel support >> > for the StarFive JH7110 SoC. >> > >> > Patch 1 add new compatible for the raspberrypi panel driver and its >> > dt-binding. >> > Patch 2 add new display mode and new probing process for raspberrypi panel >> > driver. >> > >> > Waveshare 7inch touchscreen panel is a kind of raspberrypi panel >> > which can be drived by raspberrypi panel driver. >> > >> > The series has been tested on the VisionFive 2 board. >> surprisingly i was recently working on the official Raspberry Pi >> touchscreen and was able to get it running the new way. >> >> What do i mean with the new way. There is almost nothing special to the >> Raspberry Pi touchscreen, so we should try to use/extend existing >> components like: >> >> CONFIG_DRM_PANEL_SIMPLE >> CONFIG_TOUCHSCREEN_EDT_FT5X06 >> CONFIG_DRM_TOSHIBA_TC358762 >> >> The only special part is the Attiny on the connector PCB which requires: >> >> CONFIG_REGULATOR_RASPBERRYPI_TOUCHSCREEN_ATTINY >> >> So the whole point is to avoid writing monolitic drivers for simple >> panel like that. >> >> There is a WIP branch based on top of Linux 6.7-rcX, which should >> demonstrate this approach [1]. Unfortunately it is not ready for >> upstreaming, but it has been tested on a Raspberry Pi 3 B Plus. Maybe >> this is helpful for your case. >> >> Actually i consider panel-raspberrypi-touchscreen.c as a dead end, which >> shouldn't be extended. > > Agreed. > > The panel control being bound in with the Atmel control has no hook > for the EDT5x06 touch driver to hook in and keep the power to the > touch controller active. When the panel disable gets called, bye bye > touch overlay :-( > > And I'm reading the driver change as more of a hack to get it to work > on your platform, not as adding support for the Waveshare panel > variant. > Waveshare deliberately cloned the behaviour of the Pi 7" panel in > order to make it work with the old Pi firmware drivers, so it > shouldn't need any significant changes. Where did the new timings come > from? > > Dave hi Dave : that's means the panel driver split into 3 sub-modules: panel + panel_bridge + regulator. I have a question: in the static int rpi_touchscreen_probe(struct i2c_client *i2c) { .. ver = rpi_touchscreen_i2c_read(ts, REG_ID); if (ver < 0) { dev_err(dev, "Atmel I2C read failed: %d\n", ver); return -ENODEV; } switch (ver) { case 0xde: /* ver 1 */ case 0xc3: /* ver 2 */ break; default: dev_err(dev, "Unknown Atmel firmware revision: 0x%02x\n", ver); return -ENODEV; } .. } i think this "I2C read" can use to detect whether the panel is connected to dsi controller. and when split the panel driver into 3 sub-modules, it seems the default way is connected. if I drop the panel , run modetest to check the connector status , result connected. Is there any way to detect the connection in this case? Thanks - Where did the new timings come from? - My platform dphy tx hardware has certain limitations. Only supports integer multiples of 10M bitrate: such as 160M ,170M, 180M,190M,...1G(max) as common dphy bitrate = pixclock*bpp/lanes. This value cannot match successfully in most cases. so in order to match bitrate , I choose a bitrate value around pixclock*bpp/lanes, Prevent overflow and underflow by fine-tuning the timing parameters:-( that will make the new timming value. > >> Btw there are already DT overlays in mainline which seems to use the >> Raspberry Pi 7inch panel (without touch function yet) [2]. >> >> [1] - https://github.com/lategoodbye/rpi-zero/commits/v6.7-7inch-ts >> [2] - >> https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/arch/arm64/boot/dts/freescale/imx8mm-venice-gw72xx-0x-rpidsi.dtso?h=v6.6.2&id=6b4da1354fd81adace0cda448c77d8f2a47d8474 >> >> > >> > Shengyang Chen (2): >> >dt-bindings: display: panel: raspberrypi: Add compatible property for >> > waveshare 7inch touchscreen panel >> >gpu: drm: panel: raspberrypi: add new display mode and new probing >> > process >> > >> > .../panel/raspberrypi,7inch-touchscreen.yaml | 4 +- >> > .../drm/panel/panel-raspberrypi-touchscreen.c | 99 --- >> > 2 files changed, 91 insertions(+), 12 deletions(-) >> > >>
Re: [v3 5/6] drm/vs: Add hdmi driver
On 2023/12/6 17:04, Maxime Ripard wrote: > On Mon, Dec 04, 2023 at 08:33:14PM +0800, Keith Zhao wrote: >> add hdmi driver as encoder and connect >> >> Signed-off-by: Keith Zhao >> --- >> drivers/gpu/drm/verisilicon/Kconfig | 8 + >> drivers/gpu/drm/verisilicon/Makefile| 1 + >> drivers/gpu/drm/verisilicon/starfive_hdmi.c | 849 >> drivers/gpu/drm/verisilicon/starfive_hdmi.h | 304 +++ >> drivers/gpu/drm/verisilicon/vs_drv.c| 3 + >> drivers/gpu/drm/verisilicon/vs_drv.h| 4 + >> 6 files changed, 1169 insertions(+) >> create mode 100644 drivers/gpu/drm/verisilicon/starfive_hdmi.c >> create mode 100644 drivers/gpu/drm/verisilicon/starfive_hdmi.h >> >> diff --git a/drivers/gpu/drm/verisilicon/Kconfig >> b/drivers/gpu/drm/verisilicon/Kconfig >> index e10fa97635aa..122c786e3948 100644 >> --- a/drivers/gpu/drm/verisilicon/Kconfig >> +++ b/drivers/gpu/drm/verisilicon/Kconfig >> @@ -11,3 +11,11 @@ config DRM_VERISILICON >>This driver provides VeriSilicon kernel mode >>setting and buffer management. It does not >>provide 2D or 3D acceleration. >> + >> +config DRM_VERISILICON_STARFIVE_HDMI >> +bool "Starfive HDMI extensions" >> +depends on DRM_VERISILICON >> +help >> + This selects support for StarFive soc specific extensions >> + for the Innosilicon HDMI driver. If you want to enable >> + HDMI on JH7110 based soc, you should select this option. > > I'm confused, is it a starfive or verisilicon IP? it is Innosilicon ip ,I need describe it clearer in my next. > >> diff --git a/drivers/gpu/drm/verisilicon/Makefile >> b/drivers/gpu/drm/verisilicon/Makefile >> index bf6f2b7ee480..71fadafcee13 100644 >> --- a/drivers/gpu/drm/verisilicon/Makefile >> +++ b/drivers/gpu/drm/verisilicon/Makefile >> @@ -6,4 +6,5 @@ vs_drm-objs := vs_dc_hw.o \ >> vs_drv.o \ >> vs_modeset.o \ >> vs_plane.o >> +vs_drm-$(CONFIG_DRM_VERISILICON_STARFIVE_HDMI) += starfive_hdmi.o >> obj-$(CONFIG_DRM_VERISILICON) += vs_drm.o >> diff --git a/drivers/gpu/drm/verisilicon/starfive_hdmi.c >> b/drivers/gpu/drm/verisilicon/starfive_hdmi.c >> new file mode 100644 >> index ..aa621db0dee0 >> --- /dev/null >> +++ b/drivers/gpu/drm/verisilicon/starfive_hdmi.c >> @@ -0,0 +1,849 @@ >> +// SPDX-License-Identifier: GPL-2.0-only >> +/* >> + * Copyright (C) 2023 StarFive Technology Co., Ltd. >> + */ >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +#include "starfive_hdmi.h" >> +#include "vs_drv.h" >> +#include "vs_crtc.h" >> + >> +static const char * const hdmi_clocks[] = { >> +"sysclk", >> +"mclk", >> +"bclk" >> +}; >> + >> +static struct starfive_hdmi_encoder *encoder_to_hdmi(struct drm_encoder >> *encoder) >> +{ >> +return container_of(encoder, struct starfive_hdmi_encoder, encoder); >> +} >> + >> +static struct starfive_hdmi *connector_to_hdmi(struct drm_connector >> *connector) >> +{ >> +return container_of(connector, struct starfive_hdmi, connector); >> +} >> + >> +static const struct post_pll_config post_pll_cfg_table[] = { >> +{2520, 1, 80, 13, 3, 1}, >> +{2700, 1, 40, 11, 3, 1}, >> +{3375, 1, 40, 11, 3, 1}, >> +{4900, 1, 20, 1, 3, 3}, >> +{24170, 1, 20, 1, 3, 3}, >> +{29700, 4, 20, 0, 0, 3}, >> +{59400, 4, 20, 0, 0, 0}, > > If you don't support modes > 340MHz, then there's no point in listing 594MHz > here sure . max should be 297M here. > >> +{ /* sentinel */ } >> +}; >> + >> +inline u8 hdmi_readb(struct starfive_hdmi *hdmi, u16 offset) >> +{ >> +return readl_relaxed(hdmi->regs + (offset) * 0x04); >> +} >> + >> +inline void hdmi_writeb(struct starfive_hdmi *hdmi, u16 offset, u32 val) >> +{ >> +writel_relaxed(val, hdmi->regs + (offset) * 0x04); >> +} >> + >> +inline void hd
dri-devel@lists.freedesktop.org
On 2023/12/6 16:55, Maxime Ripard wrote: > On Mon, Dec 04, 2023 at 08:33:13PM +0800, Keith Zhao wrote: >> +static const struct vs_plane_info dc_hw_planes_rev0[PLANE_NUM] = { >> +{ >> +.name = "Primary", >> +.id = PRIMARY_PLANE_0, >> +.type = DRM_PLANE_TYPE_PRIMARY, >> +.num_formats= ARRAY_SIZE(primary_overlay_format0), >> +.formats= primary_overlay_format0, >> +.num_modifiers = ARRAY_SIZE(format_modifier0), >> +.modifiers = format_modifier0, >> +.min_width = 0, >> +.min_height = 0, >> +.max_width = 4096, >> +.max_height = 4096, >> +.rotation = DRM_MODE_ROTATE_0 | >> + DRM_MODE_ROTATE_90 | >> + DRM_MODE_ROTATE_180 | >> + DRM_MODE_ROTATE_270 | >> + DRM_MODE_REFLECT_X | >> + DRM_MODE_REFLECT_Y, >> +.blend_mode = BIT(DRM_MODE_BLEND_PIXEL_NONE) | >> + BIT(DRM_MODE_BLEND_PREMULTI) | >> + BIT(DRM_MODE_BLEND_COVERAGE), >> +.color_encoding = BIT(DRM_COLOR_YCBCR_BT709) | >> + BIT(DRM_COLOR_YCBCR_BT2020), >> +.degamma_size = DEGAMMA_SIZE, >> +.min_scale = FRAC_16_16(1, 3), >> +.max_scale = FRAC_16_16(10, 1), >> +.zpos = 0, >> +.watermark = true, >> +.color_mgmt = true, >> +.roi= true, >> +}, >> +{ >> +.name = "Overlay", >> +.id = OVERLAY_PLANE_0, >> +.type = DRM_PLANE_TYPE_OVERLAY, >> +.num_formats= ARRAY_SIZE(primary_overlay_format0), >> +.formats= primary_overlay_format0, >> +.num_modifiers = ARRAY_SIZE(format_modifier0), >> +.modifiers = format_modifier0, >> +.min_width = 0, >> +.min_height = 0, >> +.max_width = 4096, >> +.max_height = 4096, >> +.rotation = DRM_MODE_ROTATE_0 | >> + DRM_MODE_ROTATE_90 | >> + DRM_MODE_ROTATE_180 | >> + DRM_MODE_ROTATE_270 | >> + DRM_MODE_REFLECT_X | >> + DRM_MODE_REFLECT_Y, >> +.blend_mode = BIT(DRM_MODE_BLEND_PIXEL_NONE) | >> + BIT(DRM_MODE_BLEND_PREMULTI) | >> + BIT(DRM_MODE_BLEND_COVERAGE), >> +.color_encoding = BIT(DRM_COLOR_YCBCR_BT709) | >> + BIT(DRM_COLOR_YCBCR_BT2020), >> +.degamma_size = DEGAMMA_SIZE, >> +.min_scale = FRAC_16_16(1, 3), >> +.max_scale = FRAC_16_16(10, 1), >> +.zpos = 1, >> +.watermark = true, >> +.color_mgmt = true, >> +.roi= true, >> +}, >> +{ >> +.name = "Overlay_1", >> +.id = OVERLAY_PLANE_1, >> +.type = DRM_PLANE_TYPE_OVERLAY, >> +.num_formats= ARRAY_SIZE(primary_overlay_format0), >> +.formats= primary_overlay_format0, >> +.num_modifiers = >> ARRAY_SIZE(secondary_format_modifiers), >> +.modifiers = secondary_format_modifiers, >> +.min_width = 0, >> +.min_height = 0, >> +.max_width = 4096, >> +.max_height = 4096, >> +.rotation = 0, >> +.blend_mode = B
Re: [v3 5/6] drm/vs: Add hdmi driver
On 2023/12/6 20:56, Maxime Ripard wrote: > On Wed, Dec 06, 2023 at 08:02:55PM +0800, Keith Zhao wrote: >> >> +static const struct of_device_id starfive_hdmi_dt_ids[] = { >> >> + { .compatible = "starfive,jh7110-inno-hdmi",}, >> > >> > So it's inno hdmi, just like Rockchip then? >> > >> > This should be a common driver. >> >> Rockchip has a inno hdmi IP. and Starfive has a inno hdmi IP. >> but the harewawre difference of them is big , it is not easy to use the >> common driver >> maybe i need the inno hdmi version here to make a distinction > > I just had a look at the rockchip header file: all the registers but the > STARFIVE_* ones are identical. > > There's no need to have two identical drivers then, please use the > rockchip driver instead. > > Maxime ok, have a simple test , edid can get . i will continue
Re: [PATCH v1 0/2] Add waveshare 7inch touchscreen panel support
On 2023/12/6 22:56, Dave Stevenson wrote: > Hi Keith > > On Wed, 6 Dec 2023 at 08:55, Keith Zhao wrote: >> >> >> >> On 2023/11/25 0:04, Dave Stevenson wrote: >> > On Fri, 24 Nov 2023 at 15:00, Stefan Wahren wrote: >> >> >> >> Hi Shengyang, >> >> >> >> [fix address of Emma] >> > >> > Not merged to master yet, but Emma has stepped back from maintenance. >> > https://lists.freedesktop.org/archives/dri-devel/2023-October/428829.html >> > Dropped from the cc. >> > >> >> Am 24.11.23 um 11:44 schrieb Shengyang Chen: >> >> > This patchset adds waveshare 7inch touchscreen panel support >> >> > for the StarFive JH7110 SoC. >> >> > >> >> > Patch 1 add new compatible for the raspberrypi panel driver and its >> >> > dt-binding. >> >> > Patch 2 add new display mode and new probing process for raspberrypi >> >> > panel driver. >> >> > >> >> > Waveshare 7inch touchscreen panel is a kind of raspberrypi panel >> >> > which can be drived by raspberrypi panel driver. >> >> > >> >> > The series has been tested on the VisionFive 2 board. >> >> surprisingly i was recently working on the official Raspberry Pi >> >> touchscreen and was able to get it running the new way. >> >> >> >> What do i mean with the new way. There is almost nothing special to the >> >> Raspberry Pi touchscreen, so we should try to use/extend existing >> >> components like: >> >> >> >> CONFIG_DRM_PANEL_SIMPLE >> >> CONFIG_TOUCHSCREEN_EDT_FT5X06 >> >> CONFIG_DRM_TOSHIBA_TC358762 >> >> >> >> The only special part is the Attiny on the connector PCB which requires: >> >> >> >> CONFIG_REGULATOR_RASPBERRYPI_TOUCHSCREEN_ATTINY >> >> >> >> So the whole point is to avoid writing monolitic drivers for simple >> >> panel like that. >> >> >> >> There is a WIP branch based on top of Linux 6.7-rcX, which should >> >> demonstrate this approach [1]. Unfortunately it is not ready for >> >> upstreaming, but it has been tested on a Raspberry Pi 3 B Plus. Maybe >> >> this is helpful for your case. >> >> >> >> Actually i consider panel-raspberrypi-touchscreen.c as a dead end, which >> >> shouldn't be extended. >> > >> > Agreed. >> > >> > The panel control being bound in with the Atmel control has no hook >> > for the EDT5x06 touch driver to hook in and keep the power to the >> > touch controller active. When the panel disable gets called, bye bye >> > touch overlay :-( >> > >> > And I'm reading the driver change as more of a hack to get it to work >> > on your platform, not as adding support for the Waveshare panel >> > variant. >> > Waveshare deliberately cloned the behaviour of the Pi 7" panel in >> > order to make it work with the old Pi firmware drivers, so it >> > shouldn't need any significant changes. Where did the new timings come >> > from? >> > >> > Dave >> hi Dave : >> that's means the panel driver split into 3 sub-modules: >> panel + panel_bridge + regulator. > > Correct. > > You'll have a fourth device in edt_ft5x06 for the touch overlay too, > which will link to the regulator driver for power control. > >> I have a question: in the >> static int rpi_touchscreen_probe(struct i2c_client *i2c) >> { >> .. >> >> ver = rpi_touchscreen_i2c_read(ts, REG_ID); >> if (ver < 0) { >> dev_err(dev, "Atmel I2C read failed: %d\n", ver); >> return -ENODEV; >> } >> >> switch (ver) { >> case 0xde: /* ver 1 */ >> case 0xc3: /* ver 2 */ >> break; >> default: >> dev_err(dev, "Unknown Atmel firmware revision: 0x%02x\n", >> ver); >> return -ENODEV; >> } >> >> .. >> } >> i think this "I2C read" can use to detect whether the panel is connected to >> dsi controller. >> >> and when split the panel driver into 3 sub-modules, it seems the default way >> is connected. >> if I drop the panel , run modetest to check the connector status , result >> connected. >> Is t
Re: [v3 5/6] drm/vs: Add hdmi driver
On 2023/12/7 17:02, Andy Yan wrote: > > > > > Hi Keith: > > > > > > > > > > > > At 2023-12-06 22:11:33, "Keith Zhao" wrote: >> >> >>On 2023/12/6 20:56, Maxime Ripard wrote: >>> On Wed, Dec 06, 2023 at 08:02:55PM +0800, Keith Zhao wrote: >>>> >> +static const struct of_device_id starfive_hdmi_dt_ids[] = { >>>> >> + { .compatible = "starfive,jh7110-inno-hdmi",}, >>>> > >>>> > So it's inno hdmi, just like Rockchip then? >>>> > >>>> > This should be a common driver. >>>> >>>> Rockchip has a inno hdmi IP. and Starfive has a inno hdmi IP. >>>> but the harewawre difference of them is big , it is not easy to use the >>>> common driver >>>> maybe i need the inno hdmi version here to make a distinction >>> >>> I just had a look at the rockchip header file: all the registers but the >>> STARFIVE_* ones are identical. >>> >>> There's no need to have two identical drivers then, please use the >>> rockchip driver instead. >>> >>> Maxime >> >>ok, have a simple test , edid can get . i will continue > > Maybe you can take drivers/gpu/drm/bridge/synopsys/dw-hdmi as a reference, > this > is also a hdmi ip used by rockchip/meson/sunxi/jz/imx。 > We finally make it share one driver。 >> hi Andy: dw_hdmi seems a good choice , it can handle inno hdmi hardware by define its dw_hdmi_plat_data. does it means i can write own driver files such as(dw_hdmi-starfive.c) based on dw_hdmi instead of add plat_data in inno_hdmi.c Thanks for pointing this out!!! >> >>___ >>linux-riscv mailing list >>linux-ri...@lists.infradead.org >>http://lists.infradead.org/mailman/listinfo/linux-riscv
dri-devel@lists.freedesktop.org
On 2023/12/7 16:41, Icenowy Zheng wrote: > 在 2023-12-04星期一的 20:33 +0800,Keith Zhao写道: > *snip* > >> +static void update_cursor_plane(struct vs_dc *dc, struct vs_plane >> *plane, >> + struct drm_plane *drm_plane, >> + struct drm_atomic_state *drm_state) >> +{ >> + struct drm_plane_state *state = >> drm_atomic_get_new_plane_state(drm_state, >> + >> drm_plane); >> + struct vs_plane_state *plane_state = >> to_vs_plane_state(state); >> + struct drm_framebuffer *drm_fb = state->fb; >> + struct dc_hw_cursor cursor; >> + >> + cursor.address = plane_state->dma_addr[0]; >> + cursor.x = state->crtc_x; >> + cursor.y = state->crtc_y; > > From my experiments on poking with registers on T-Head TH1520 (also > uses DC8200 display controller and a similar driver), the DC8200 > hardware have a different definition of cursor position X and Y with > the CRTC plane state. > > For CRTC plane state, hot_x and hot_y are only provided as reference, > and the cursor should be displayed with its (0,0) drawn to (crtc_x, > crtc_y) ([XY]_crtc are values specified in CRTC state, the right part > of the assignments here), when the cursor is moved to (0,0) but the hot > point is not (0,0), it could be negative. > > However, for DC8200 registers definition, cursor XY position could not > be negative -- the cursor will disappear then; because in its > definition, the cursor XY position should be where the cursor is > pointing to, instead of its (0,0). DC8200 will draw (0,0) of the cursor > to (x - hot_x, y - hot_y). So to met the expectation of the KMS plane > settings, the DC8200 position should be set to (crtc_x + hot_x, crtc_y > + hot_y) instead. Thus these two lines of code should be: > > ``` > cursor.x = state->crtc_x + drm_fb->hot_x; > cursor.y = state->crtc_y + drm_fb->hot_y; > ``` > > >> + cursor.hot_x = drm_fb->hot_x; >> + cursor.hot_y = drm_fb->hot_y; >> + cursor.display_id = to_vs_display_id(dc, state->crtc); >> + update_cursor_size(state, &cursor); >> + cursor.enable = true; >> + >> + dc_hw_update_cursor(&dc->hw, cursor.display_id, &cursor); >> +} > *snip hello Icenowy: you are deep understanding on dc8200. by the way of practice I tested this change on the debian desktop, is there a way to compare the cursor behavior change? Thanks
Re: [v3 5/6] drm/vs: Add hdmi driver
On 2023/12/8 8:37, Andy Yan wrote: > Hi Keth: > > > > > > > 在 2023-12-07 18:48:13,"Keith Zhao" 写道: >> >> >>On 2023/12/7 17:02, Andy Yan wrote: >>> >>> >>> >>> >>> Hi Keith: >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> At 2023-12-06 22:11:33, "Keith Zhao" wrote: >>>> >>>> >>>>On 2023/12/6 20:56, Maxime Ripard wrote: >>>>> On Wed, Dec 06, 2023 at 08:02:55PM +0800, Keith Zhao wrote: >>>>>> >> +static const struct of_device_id starfive_hdmi_dt_ids[] = { >>>>>> >> + { .compatible = "starfive,jh7110-inno-hdmi",}, >>>>>> > >>>>>> > So it's inno hdmi, just like Rockchip then? >>>>>> > >>>>>> > This should be a common driver. >>>>>> >>>>>> Rockchip has a inno hdmi IP. and Starfive has a inno hdmi IP. >>>>>> but the harewawre difference of them is big , it is not easy to use the >>>>>> common driver >>>>>> maybe i need the inno hdmi version here to make a distinction >>>>> >>>>> I just had a look at the rockchip header file: all the registers but the >>>>> STARFIVE_* ones are identical. >>>>> >>>>> There's no need to have two identical drivers then, please use the >>>>> rockchip driver instead. >>>>> >>>>> Maxime >>>> >>>>ok, have a simple test , edid can get . i will continue >>> >>> Maybe you can take drivers/gpu/drm/bridge/synopsys/dw-hdmi as a reference, >>> this >>> is also a hdmi ip used by rockchip/meson/sunxi/jz/imx。 >>> We finally make it share one driver。 >>>> >>hi Andy: >> >>dw_hdmi seems a good choice , it can handle inno hdmi hardware by define its >>dw_hdmi_plat_data. >>does it means i can write own driver files such as(dw_hdmi-starfive.c) based >>on dw_hdmi instead of add plat_data in inno_hdmi.c >> > > I think the process maybe like this: > > 1. split the inno_hdmi.c under rockchip to inno_hdmi.c(the common part), > inno_hdmi-rockchip.c(the soc specific part) > 2. move the common part inno_hdmi.c to drivers/gpu/drm/bridge/innosilicon/ > 3. add startfive specific part, inno_hdmi-startfive.c > > bellow git log from kernel three show how we convert dw_hdmi to a common > driver: > > > > 12b9f204e804 drm: bridge/dw_hdmi: add rockchip rk3288 support > 74af9e4d03b8 dt-bindings: Add documentation for rockchip dw hdmi > d346c14eeea9 drm: bridge/dw_hdmi: add function dw_hdmi_phy_enable_spare > a4d3b8b050d5 drm: bridge/dw_hdmi: clear i2cmphy_stat0 reg in > hdmi_phy_wait_i2c_done > 632d035bace2 drm: bridge/dw_hdmi: add mode_valid support > 0cd9d1428322 drm: bridge/dw_hdmi: add support for multi-byte register width > access > cd152393967e dt-bindings: add document for dw_hdmi > b21f4b658df8 drm: imx: imx-hdmi: move imx-hdmi to bridge/dw_hdmi > aaa757a092c2 drm: imx: imx-hdmi: split phy configuration to platform driver > 3d1b35a3d9f3 drm: imx: imx-hdmi: convert imx-hdmi to drm_bridge mode > c2c3848851a7 drm: imx: imx-hdmi: return defer if can't get ddc i2c adapter > b587833933de drm: imx: imx-hdmi: make checkpatch happy > hi Andy: I got you means, as I don't have a rockchip board on hand , to split the inno_hdmi.c can not be tested. how adout this idea: 1、split the starfive_hdmi.c under verisilicion to inno_hdmi.c(the common part), inno_hdmi-starfive.c(the soc specific part) 2. move the common part inno_hdmi.c to drivers/gpu/drm/bridge/innosilicon/ 3. In the future, inno hdmi.c under rockchip will reuse the public driver. > >>Thanks for pointing this out!!! >> >>>> >>>>___ >>>>linux-riscv mailing list >>>>linux-ri...@lists.infradead.org >>>>http://lists.infradead.org/mailman/listinfo/linux-riscv >> >>___ >>linux-riscv mailing list >>linux-ri...@lists.infradead.org >>http://lists.infradead.org/mailman/listinfo/linux-riscv
Re: [v3 3/6] drm/vs: Register DRM device
hi Philipp: On 2023/12/4 21:30, Philipp Zabel wrote: > Hi Keith, > > On Mo, 2023-12-04 at 20:33 +0800, Keith Zhao wrote: >> Implement drm device registration interface >> >> Signed-off-by: Keith Zhao >> --- > [...] >> diff --git a/drivers/gpu/drm/verisilicon/Kconfig >> b/drivers/gpu/drm/verisilicon/Kconfig >> new file mode 100644 >> index ..e10fa97635aa >> --- /dev/null >> +++ b/drivers/gpu/drm/verisilicon/Kconfig >> @@ -0,0 +1,13 @@ >> +# SPDX-License-Identifier: GPL-2.0 >> +config DRM_VERISILICON >> +tristate "DRM Support for VeriSilicon" >> +depends on DRM >> +select DRM_KMS_HELPER >> +select DRM_GEM_DMA_HELPER >> +select CMA >> +select DMA_CMA >> +help >> + Choose this option if you have a VeriSilicon soc chipset. > > This seems a bit generic. Doesn't the VeriSilicon display controller IP > used on JH7110 have a product name? yes , there is a product name "dc8200", I will match it. > > [...] >> diff --git a/drivers/gpu/drm/verisilicon/vs_drv.c >> b/drivers/gpu/drm/verisilicon/vs_drv.c >> new file mode 100644 >> index ..4fb1f29ef84b >> --- /dev/null >> +++ b/drivers/gpu/drm/verisilicon/vs_drv.c >> @@ -0,0 +1,316 @@ >> +// SPDX-License-Identifier: GPL-2.0 > [...] >> +static void vs_drm_device_release_clocks(void *res) >> +{ >> +struct vs_drm_device *priv = res; >> +unsigned int i; >> + >> +reset_control_bulk_assert(priv->nrsts, priv->rst_vout); >> + >> +for (i = 0; i < priv->clk_count; ++i) { >> +if (priv->clks[i]) { >> +clk_disable_unprepare(priv->clks[i]); >> +clk_put(priv->clks[i]); >> +} >> +} > > Why not use the bulk API for clk as well? ok , will do it next version > > [...] >> +static int vs_drm_device_init_clocks(struct vs_drm_device *priv) >> +{ >> +struct drm_device *dev = &priv->base; >> +struct platform_device *pdev = to_platform_device(dev->dev); >> +struct device_node *of_node = pdev->dev.of_node; >> +struct clk *clock; >> +unsigned int i; >> +int ret; >> + >> +if (dev_get_platdata(&pdev->dev) || !of_node) >> +return 0; >> + >> +priv->nrsts = ARRAY_SIZE(priv->rst_vout); >> +for (int i = 0; i < priv->nrsts; ++i) >> +priv->rst_vout[i].id = vout_resets[i]; >> +ret = devm_reset_control_bulk_get_shared(dev->dev, priv->nrsts, >> + priv->rst_vout); > > I would request resets and clocks in _probe(). > > If component_bind_all() returns -EPROBE_DEFER because of a still > missing DSI panel backlight or similar, this doesn't have to be done > multiple times. I got what you mean. component_bind_all should be done multiple times to prevent the dsi panel driver from lagging load. in my drm subsystem , there are 2 pipeline +--+ | | | | ++ | +---+ | +---+ +--+ +--+ |+->+ dc controller 0 +--->->+HDMICtl| ->+ PHY +-->+PANEL0+ |AXI | | +---+ | +---+ +--+ +--+ || | | || | | || | | || | | |APB | | +---+ +-++--+ +---+ |+->+ dc controller 1 +--->>+ dsiTx +--->+DPHY +->+ PANEL1+ || | +---+ +-++--+ +---+ ++ | | +--+ component_bind_all will bind the hdmi encoder and dsi encoder . binding the hdmi encoder will always return ok . binging the dsi encoder has a question : I used the panel-raspberrypi-touchscreen.c as panel driver , this driver is a i2c device and it use a i2c command to read reg ID if read success , it will do drm_panel_add. if I disconnect the panel ,it will not do drm_panel_add. dsiTx will fail to find panel , The consequence is that the inputbridge cannot be created , also outputbridge cannot be created. for encoder bind , it will fail to find the input bridge of dsi. Under this premise, although returning -EPROBE_DEFER allows bind to be executed multiple times, the final result is that the entire bind fails. returning -EPROBE_DEFER can s
Re: [v3 5/6] drm/vs: Add hdmi driver
hi Maxime: hi Andy: On 2023/12/8 17:14, Maxime Ripard wrote: > Hi, > > On Fri, Dec 08, 2023 at 11:23:37AM +0800, Andy Yan wrote: >> 在 2023-12-08 11:00:31,"Keith Zhao" 写道: >> > >> > >> >On 2023/12/8 8:37, Andy Yan wrote: >> >> Hi Keth: >> >> >> >> >> >> >> >> >> >> >> >> >> >> 在 2023-12-07 18:48:13,"Keith Zhao" 写道: >> >>> >> >>> >> >>>On 2023/12/7 17:02, Andy Yan wrote: >> >>>> >> >>>> >> >>>> >> >>>> >> >>>> Hi Keith: >> >>>> >> >>>> >> >>>> >> >>>> >> >>>> >> >>>> >> >>>> >> >>>> >> >>>> >> >>>> >> >>>> >> >>>> At 2023-12-06 22:11:33, "Keith Zhao" >> >>>> wrote: >> >>>>> >> >>>>> >> >>>>>On 2023/12/6 20:56, Maxime Ripard wrote: >> >>>>>> On Wed, Dec 06, 2023 at 08:02:55PM +0800, Keith Zhao wrote: >> >>>>>>> >> +static const struct of_device_id starfive_hdmi_dt_ids[] = { >> >>>>>>> >> + { .compatible = "starfive,jh7110-inno-hdmi",}, >> >>>>>>> > >> >>>>>>> > So it's inno hdmi, just like Rockchip then? >> >>>>>>> > >> >>>>>>> > This should be a common driver. >> >>>>>>> >> >>>>>>> Rockchip has a inno hdmi IP. and Starfive has a inno hdmi IP. >> >>>>>>> but the harewawre difference of them is big , it is not easy to use >> >>>>>>> the common driver >> >>>>>>> maybe i need the inno hdmi version here to make a distinction >> >>>>>> >> >>>>>> I just had a look at the rockchip header file: all the registers but >> >>>>>> the >> >>>>>> STARFIVE_* ones are identical. >> >>>>>> >> >>>>>> There's no need to have two identical drivers then, please use the >> >>>>>> rockchip driver instead. >> >>>>>> >> >>>>>> Maxime >> >>>>> >> >>>>>ok, have a simple test , edid can get . i will continue >> >>>> >> >>>> Maybe you can take drivers/gpu/drm/bridge/synopsys/dw-hdmi as a >> >>>> reference, this >> >>>> is also a hdmi ip used by rockchip/meson/sunxi/jz/imx。 >> >>>> We finally make it share one driver。 >> >>>>> >> >>>hi Andy: >> >>> >> >>>dw_hdmi seems a good choice , it can handle inno hdmi hardware by define >> >>>its dw_hdmi_plat_data. >> >>>does it means i can write own driver files such as(dw_hdmi-starfive.c) >> >>>based on dw_hdmi instead of add plat_data in inno_hdmi.c >> >>> >> >> >> >> I think the process maybe like this: >> >> >> >> 1. split the inno_hdmi.c under rockchip to inno_hdmi.c(the common part), >> >> inno_hdmi-rockchip.c(the soc specific part) >> >> 2. move the common part inno_hdmi.c to drivers/gpu/drm/bridge/innosilicon/ >> >> 3. add startfive specific part, inno_hdmi-startfive.c >> >> >> >> bellow git log from kernel three show how we convert dw_hdmi to a common >> >> driver: >> >> >> >> >> >> >> >> 12b9f204e804 drm: bridge/dw_hdmi: add rockchip rk3288 support >> >> 74af9e4d03b8 dt-bindings: Add documentation for rockchip dw hdmi >> >> d346c14eeea9 drm: bridge/dw_hdmi: add function dw_hdmi_phy_enable_spare >> >> a4d3b8b050d5 drm: bridge/dw_hdmi: clear i2cmphy_stat0 reg in >> >> hdmi_phy_wait_i2c_done >> >> 632d035bace2 drm: bridge/dw_hdmi: add mode_valid support >> >> 0cd9d1428322 drm: bridge/dw_hdmi: add support for multi-byte register >> >> width access >> >> cd152393967e dt-bindings: add document for dw_hdmi >> >> b21f4b658df8 drm: imx: imx-hdmi: move imx-hdmi to bridge/dw_hdmi >> >> aaa757a092c2 drm: imx: imx-hdmi: split phy configuration to platform >> >> driver >> >> 3d1b35a3d9f3 drm: imx: imx-hdmi: convert imx-hdmi to drm_bridge mode >> >> c2c3848851a7 drm: imx: imx-hdmi: return defer if can't get ddc i2c adapter >> >> b587833933de drm: imx: imx-hdmi: make checkpatch happy >> >> >> >hi Andy: >> >I got you means, >> >as I don't have a rockchip board on hand , to split the inno_hdmi.c can not >> >be tested. >> > >> >how adout this idea: >> >1、split the starfive_hdmi.c under verisilicion to inno_hdmi.c(the common >> >part), inno_hdmi-starfive.c(the soc specific part) >> >2. move the common part inno_hdmi.c to drivers/gpu/drm/bridge/innosilicon/ >> >3. In the future, inno hdmi.c under rockchip will reuse the public driver. >> >> I am not sure if drm maintainers are happy with this。 > > Not really, no. > > Because we would still have two drivers for the same controller, and a > common one that haven't really been tested on anything but a single > platform. So arguably a worse situation than what you were suggesting in > the first place. > > The best solution would be to find someone with a Rockchip board to test > your changes, or to get one if it's doable so you can test yourself. ok I will also try to buy a Rockchip 3036 board for self-test. According to the commit log idea provided by Andy before, make the inno_hdmi driver common module. would the steps be ok? (if I tested rockchip and starifve pass) 1. split the inno_hdmi.c under rockchip to inno_hdmi.c(the common part), inno_hdmi-rockchip.c(the soc specific part) 2. move the common part inno_hdmi.c to drivers/gpu/drm/bridge/innosilicon/ 3. add startfive specific part, inno_hdmi-startfive.c Thanks > > Maxime
Re: [v3 5/6] drm/vs: Add hdmi driver
On 2023/12/11 20:13, Andy Yan wrote: > Hi Keith: > > 在 2023-12-11 18:24:35,"Keith Zhao" 写道: >>hi Maxime: >>hi Andy: >> >>On 2023/12/8 17:14, Maxime Ripard wrote: >>> Hi, >>> >>> On Fri, Dec 08, 2023 at 11:23:37AM +0800, Andy Yan wrote: >>>> 在 2023-12-08 11:00:31,"Keith Zhao" 写道: >>>> > >>>> > >>>> >On 2023/12/8 8:37, Andy Yan wrote: >>>> >> Hi Keth: >>>> >> >>>> >> >>>> >> >>>> >> >>>> >> >>>> >> >>>> >> 在 2023-12-07 18:48:13,"Keith Zhao" 写道: >>>> >>> >>>> >>> >>>> >>>On 2023/12/7 17:02, Andy Yan wrote: >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> Hi Keith: >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> At 2023-12-06 22:11:33, "Keith Zhao" >>>> >>>> wrote: >>>> >>>>> >>>> >>>>> >>>> >>>>>On 2023/12/6 20:56, Maxime Ripard wrote: >>>> >>>>>> On Wed, Dec 06, 2023 at 08:02:55PM +0800, Keith Zhao wrote: >>>> >>>>>>> >> +static const struct of_device_id starfive_hdmi_dt_ids[] = { >>>> >>>>>>> >> + { .compatible = "starfive,jh7110-inno-hdmi",}, >>>> >>>>>>> > >>>> >>>>>>> > So it's inno hdmi, just like Rockchip then? >>>> >>>>>>> > >>>> >>>>>>> > This should be a common driver. >>>> >>>>>>> >>>> >>>>>>> Rockchip has a inno hdmi IP. and Starfive has a inno hdmi IP. >>>> >>>>>>> but the harewawre difference of them is big , it is not easy to >>>> >>>>>>> use the common driver >>>> >>>>>>> maybe i need the inno hdmi version here to make a distinction >>>> >>>>>> >>>> >>>>>> I just had a look at the rockchip header file: all the registers >>>> >>>>>> but the >>>> >>>>>> STARFIVE_* ones are identical. >>>> >>>>>> >>>> >>>>>> There's no need to have two identical drivers then, please use the >>>> >>>>>> rockchip driver instead. >>>> >>>>>> >>>> >>>>>> Maxime >>>> >>>>> >>>> >>>>>ok, have a simple test , edid can get . i will continue >>>> >>>> >>>> >>>> Maybe you can take drivers/gpu/drm/bridge/synopsys/dw-hdmi as a >>>> >>>> reference, this >>>> >>>> is also a hdmi ip used by rockchip/meson/sunxi/jz/imx。 >>>> >>>> We finally make it share one driver。 >>>> >>>>> >>>> >>>hi Andy: >>>> >>> >>>> >>>dw_hdmi seems a good choice , it can handle inno hdmi hardware by >>>> >>>define its dw_hdmi_plat_data. >>>> >>>does it means i can write own driver files such as(dw_hdmi-starfive.c) >>>> >>>based on dw_hdmi instead of add plat_data in inno_hdmi.c >>>> >>> >>>> >> >>>> >> I think the process maybe like this: >>>> >> >>>> >> 1. split the inno_hdmi.c under rockchip to inno_hdmi.c(the common >>>> >> part), inno_hdmi-rockchip.c(the soc specific part) >>>> >> 2. move the common part inno_hdmi.c to >>>> >> drivers/gpu/drm/bridge/innosilicon/ >>>> >> 3. add startfive specific part, inno_hdmi-startfive.c >>>> >> >>>> >> bellow git log from kernel three show how we convert dw_hdmi to a >>>> >> common driver:
RE: [PATCH v5 3/9] drm: bridge: inno-hdmi: add inno bridge driver.
> -Original Message- > From: Uwe Kleine-König > Sent: 2024年11月20日 22:56 > To: Keith Zhao > Cc: devicet...@vger.kernel.org; dri-devel@lists.freedesktop.org; > andrzej.ha...@intel.com; neil.armstr...@linaro.org; rf...@kernel.org; > laurent.pinch...@ideasonboard.com; jernej.skra...@gmail.com; > maarten.lankho...@linux.intel.com; mrip...@kernel.org; > tzimmerm...@suse.de; airl...@gmail.com; sim...@ffwll.ch; > r...@kernel.org; krzk...@kernel.org; conor...@kernel.org; > h...@rock-chips.com; he...@sntech.de; andy@rock-chips.com; William Qiu > ; Xingyu Wu ; > ker...@esmil.dk; paul.walms...@sifive.com; pal...@dabbelt.com; > a...@eecs.berkeley.edu; p.za...@pengutronix.de; Changhuang Liang > ; Jack Zhu ; > linux-ker...@vger.kernel.org > Subject: Re: [PATCH v5 3/9] drm: bridge: inno-hdmi: add inno bridge driver. > > Hello, > > On Wed, Nov 20, 2024 at 02:18:42PM +0800, keith zhao wrote: > > +struct platform_driver inno_hdmi_driver = { > > + .probe = inno_hdmi_rockchip_probe, > > + .remove_new = inno_hdmi_rockchip_remove, > > Please use .remove instead of .remove_new. > Thank you for the clarification regarding .remove_new. I understand that it's a relic and that new drivers should implement .remove(). I have a question. One of the changes in this patch is to rename some function interfaces. The original code is like this. struct platform_driver inno_hdmi_driver = { .probe = inno_hdmi_probe, .remove_new = inno_hdmi_remove, .driver = { .name = "innohdmi-rockchip", .of_match_table = inno_hdmi_dt_ids, }, }; Rename inno_hdmi_probe and inno_hdmi_remove struct platform_driver inno_hdmi_driver = { .probe = inno_hdmi_rockchip_probe, .remove_new = inno_hdmi_rockchip_remove, .driver = { .name = "innohdmi-rockchip", .of_match_table = inno_hdmi_dt_ids, }, }; Based on the principle of maintaining consistency, does it(remove_new) need to be changed? Thanks > Best regards > Uwe
[PATCH v5 4/9] drm/vs: Add Hardware Functions for VS DC8200
This commit introduces hardware-based APIs for the VS DRM related to the DC8200 Signed-off-by: keith zhao --- MAINTAINERS|1 + drivers/gpu/drm/Kconfig|2 + drivers/gpu/drm/Makefile |1 + drivers/gpu/drm/verisilicon/Kconfig| 13 + drivers/gpu/drm/verisilicon/Makefile |5 + drivers/gpu/drm/verisilicon/vs_dc_hw.c | 1104 drivers/gpu/drm/verisilicon/vs_dc_hw.h | 492 +++ drivers/gpu/drm/verisilicon/vs_type.h | 54 ++ 8 files changed, 1672 insertions(+) create mode 100644 drivers/gpu/drm/verisilicon/Kconfig create mode 100644 drivers/gpu/drm/verisilicon/Makefile create mode 100644 drivers/gpu/drm/verisilicon/vs_dc_hw.c create mode 100644 drivers/gpu/drm/verisilicon/vs_dc_hw.h create mode 100644 drivers/gpu/drm/verisilicon/vs_type.h diff --git a/MAINTAINERS b/MAINTAINERS index 7766ee0bdd74..55d6bccdd036 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7440,6 +7440,7 @@ T:git https://gitlab.freedesktop.org/drm/misc/kernel.git F: Documentation/devicetree/bindings/display/bridge/innosilicon,inno-hdmi.yaml F: Documentation/devicetree/bindings/display/starfive/ F: drivers/gpu/drm/bridge/innosilicon/ +F: drivers/gpu/drm/verisilicon F: include/drm/bridge/inno_hdmi.h DRM DRIVER FOR SYNAPTICS R63353 PANELS diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index 1df4e627e3d3..0abd0ecbe1e5 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -481,6 +481,8 @@ source "drivers/gpu/drm/sprd/Kconfig" source "drivers/gpu/drm/imagination/Kconfig" +source "drivers/gpu/drm/verisilicon/Kconfig" + config DRM_HYPERV tristate "DRM Support for Hyper-V synthetic video device" depends on DRM && PCI && MMU && HYPERV diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index 3894f43f6d47..9450b90d5df1 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -223,3 +223,4 @@ obj-y += solomon/ obj-$(CONFIG_DRM_SPRD) += sprd/ obj-$(CONFIG_DRM_LOONGSON) += loongson/ obj-$(CONFIG_DRM_POWERVR) += imagination/ +obj-$(CONFIG_DRM_VERISILICON_DC8200) += verisilicon/ diff --git a/drivers/gpu/drm/verisilicon/Kconfig b/drivers/gpu/drm/verisilicon/Kconfig new file mode 100644 index ..874e8bcde5d5 --- /dev/null +++ b/drivers/gpu/drm/verisilicon/Kconfig @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-2.0 +config DRM_VERISILICON_DC8200 + tristate "DRM Support for VeriSilicon DC8200" + depends on DRM + select DRM_KMS_HELPER + select DRM_GEM_DMA_HELPER + select DMA_CMA if HAVE_DMA_CONTIGUOUS + select CMA if HAVE_DMA_CONTIGUOUS + help + Choose this option if you have a VeriSilicon DC8200 chipset. + This driver provides VeriSilicon kernel mode + setting and buffer management. It does not + provide 2D or 3D acceleration. diff --git a/drivers/gpu/drm/verisilicon/Makefile b/drivers/gpu/drm/verisilicon/Makefile new file mode 100644 index ..7da54b259940 --- /dev/null +++ b/drivers/gpu/drm/verisilicon/Makefile @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0 + +vs_drm-objs := vs_dc_hw.o + +obj-$(CONFIG_DRM_VERISILICON_DC8200) += vs_drm.o diff --git a/drivers/gpu/drm/verisilicon/vs_dc_hw.c b/drivers/gpu/drm/verisilicon/vs_dc_hw.c new file mode 100644 index ..44c216fdf78d --- /dev/null +++ b/drivers/gpu/drm/verisilicon/vs_dc_hw.c @@ -0,0 +1,1104 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) VeriSilicon Holdings Co., Ltd. + */ + +#include +#include +#include +#include +#include +#include + +#include "vs_dc_hw.h" + +static const u32 horkernel[] = { + 0x, 0x2000, 0x2000, 0x, + 0x, 0x, 0x23fd1c03, 0x, + 0x, 0x, 0x181f, 0x27e1, + 0x, 0x, 0x, 0x2b981468, + 0x, 0x, 0x, 0x10f0, + 0x2f10, 0x, 0x, 0x, + 0x32390dc7, 0x, 0x, 0x, + 0x0af5, 0x350b, 0x, 0x, + 0x, 0x3781087f, 0x, 0x, + 0x, 0x0666, 0x399a, 0x, + 0x, 0x, 0x3b5904a7, 0x, + 0x, 0x, 0x033c, 0x3cc4, + 0x, 0x, 0x, 0x3de1021f, + 0x, 0x, 0x, 0x0147, + 0x3eb9, 0x, 0x, 0x, + 0x3f5300ad, 0x, 0x, 0x, + 0x0048, 0x3fb8, 0x, 0x, + 0x, 0x3fef0011, 0x, 0x, + 0x, 0x, 0x4000, 0x, + 0x, 0x, 0x20002000, 0x, + 0x, 0x
[PATCH v5 0/9] drm/verisilicon : support DC8200 and inno hdmi
Verisilicon/DC8200 display controller IP has 2 display pipes and each pipe support a primary plane and a cursor plane . In addition, there are 4 overlay planes as 2 display pipes common resources. The first display pipe is bound to the inno HDMI encoder. The second display pipe is bound to Internal custom encoder, which is used to find dsi bridge by dts node. This patchset should be applied on next branch. V1: Changes since v1: - Further standardize the yaml file. - Dts naming convention improved. - Fix the problem of compiling and loading ko files. - Use drm new api to automatically manage resources. - Drop vs_crtc_funcs&vs_plane_funcs, subdivide the plane's help interface. - Reduce the modifiers unused. - Optimize the hdmi driver code V2: Changes since v2: - fix the error about checking the yaml file. - match drm driver GEM DMA API. - Delete the custom crtc property . - hdmi use drmm_ new api to automatically manage resources. - update the modifiers comments. - enabling KASAN, fix the error during removing module V3: Changes since v3: - Delete the custom plane property. - Delete the custom fourcc modifiers. - Adjust the calculation mode of hdmi pixclock. - Add match data for dc8200 driver. - Adjust some magic values. - Add a simple encoder for dsi output. V4: Changes since v4: - Delete the display subsystem module as all crtcs and planes are a driver. - Delete the custom struct, directly use the drm struct data. - Tidy up the inno hdmi public interface. - Add a simple encoder for dsi output. V5: Changes since v5: - Refine the Innosilicon HDMI by quoting bridge abstracting. - Delete the encoder driver, which is created directly by internal functions. - Adapt to the changes in kernel upgrade APIs, such as drm_client_setup. keith zhao (9): dt-bindings: display: bindings for starfive,JH7110 display pipeline riscv: dts: Add display property drm: bridge: inno-hdmi: add inno bridge driver. drm/vs: Add Hardware Functions for VS DC8200 drm/vs: Add Base API for VS Mode Configuration drm/vs: Add CRTC Functions drm/vs: Add VS Plane API drm/vs: Add Innosilicon HDMI Support drm/vs: Add VS DRM Master Driver for JH7110 SoC .../display/bridge/innosilicon,inno-hdmi.yaml | 45 + .../display/rockchip/rockchip,inno-hdmi.yaml | 27 +- .../starfive/starfive,jh7110-dc8200.yaml | 176 +++ .../starfive/starfive,jh7110-inno-hdmi.yaml | 91 ++ .../soc/starfive/starfive,jh7110-syscon.yaml |1 + MAINTAINERS | 11 + .../boot/dts/starfive/jh7110-common.dtsi | 125 ++ arch/riscv/boot/dts/starfive/jh7110.dtsi | 41 + drivers/gpu/drm/Kconfig |2 + drivers/gpu/drm/Makefile |1 + drivers/gpu/drm/bridge/Kconfig|2 + drivers/gpu/drm/bridge/Makefile |1 + drivers/gpu/drm/bridge/innosilicon/Kconfig|6 + drivers/gpu/drm/bridge/innosilicon/Makefile |2 + .../gpu/drm/bridge/innosilicon/inno-hdmi.c| 376 ++ .../gpu/drm/bridge/innosilicon/inno-hdmi.h| 34 + drivers/gpu/drm/rockchip/Kconfig |1 + drivers/gpu/drm/rockchip/Makefile |2 +- drivers/gpu/drm/rockchip/inno_hdmi-rockchip.c | 690 +++ .../{inno_hdmi.h => inno_hdmi-rockchip.h} |0 drivers/gpu/drm/rockchip/inno_hdmi.c | 1025 --- drivers/gpu/drm/verisilicon/Kconfig | 32 + drivers/gpu/drm/verisilicon/Makefile | 10 + .../gpu/drm/verisilicon/inno_hdmi-starfive.c | 553 + .../gpu/drm/verisilicon/inno_hdmi-starfive.h | 194 +++ drivers/gpu/drm/verisilicon/vs_crtc.c | 241 drivers/gpu/drm/verisilicon/vs_crtc.h | 42 + drivers/gpu/drm/verisilicon/vs_dc_hw.c| 1104 + drivers/gpu/drm/verisilicon/vs_dc_hw.h| 492 drivers/gpu/drm/verisilicon/vs_drv.c | 777 drivers/gpu/drm/verisilicon/vs_drv.h | 41 + drivers/gpu/drm/verisilicon/vs_modeset.c | 31 + drivers/gpu/drm/verisilicon/vs_modeset.h | 10 + drivers/gpu/drm/verisilicon/vs_plane.c| 358 ++ drivers/gpu/drm/verisilicon/vs_plane.h| 27 + drivers/gpu/drm/verisilicon/vs_type.h | 54 + include/drm/bridge/inno_hdmi.h| 56 + 37 files changed, 5630 insertions(+), 1051 deletions(-) create mode 100644 Documentation/devicetree/bindings/display/bridge/innosilicon,inno-hdmi.yaml create mode 100644 Documentation/devicetree/bindings/display/starfive/starfive,jh7110-dc8200.yaml create mode 100644 Documentation/devicetree/bindings/display/starfive/starfive,jh7110-inno-hdmi.yaml create mode 100644 drivers/gpu/drm/bridge/innosilicon/Kconfig create mode 100644 drivers/gpu/drm/bridge/innosilicon/Makefile create mode 100644 drivers/gpu/drm/bridge/innosilicon/inno-hdmi.c create mode 100644 drivers/gpu/drm/bridge/innosilicon/inno-hdmi.h create mode 100644 drivers/gpu/
[PATCH v5 1/9] dt-bindings: display: bindings for starfive, JH7110 display pipeline
- Added bindings to support the display subsystem on the JH7110 SoC. - Included the DC8200 display controller and Inno HDMI controller. - Created innosilicon,inno-hdmi.yaml schema containing common properties for the Inno DesignWare HDMI TX controller. This isn't a full device tree binding specification, but is intended to be referenced by platform-specific bindings for the IP core. Signed-off-by: keith zhao --- .../display/bridge/innosilicon,inno-hdmi.yaml | 45 + .../display/rockchip/rockchip,inno-hdmi.yaml | 27 +-- .../starfive/starfive,jh7110-dc8200.yaml | 176 ++ .../starfive/starfive,jh7110-inno-hdmi.yaml | 91 + .../soc/starfive/starfive,jh7110-syscon.yaml | 1 + MAINTAINERS | 8 + 6 files changed, 323 insertions(+), 25 deletions(-) create mode 100644 Documentation/devicetree/bindings/display/bridge/innosilicon,inno-hdmi.yaml create mode 100644 Documentation/devicetree/bindings/display/starfive/starfive,jh7110-dc8200.yaml create mode 100644 Documentation/devicetree/bindings/display/starfive/starfive,jh7110-inno-hdmi.yaml diff --git a/Documentation/devicetree/bindings/display/bridge/innosilicon,inno-hdmi.yaml b/Documentation/devicetree/bindings/display/bridge/innosilicon,inno-hdmi.yaml new file mode 100644 index ..f2543aebc312 --- /dev/null +++ b/Documentation/devicetree/bindings/display/bridge/innosilicon,inno-hdmi.yaml @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/bridge/innosilicon,inno-hdmi.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Common Properties for Innosilicon HDMI TX IP + +maintainers: + - keith zhao + +description: | + Innosilicon HDMI TX is an HDMI transmission device integrated into the zap SoC. + This document specifies the device tree properties for the INNO HDMI IP core. + It is intended to be referenced by platform-specific device tree bindings, + which will determine the necessity of each property. + +properties: + reg: +maxItems: 1 + + interrupts: +maxItems: 1 + + ports: +$ref: /schemas/graph.yaml#/properties/ports + +properties: + port@0: +$ref: /schemas/graph.yaml#/properties/port +description: + Port node with one endpoint connected to a display controller node. + + port@1: +$ref: /schemas/graph.yaml#/properties/port +description: + Port node with one endpoint connected to a hdmi-connector node. + +required: + - port@0 + - port@1 + +additionalProperties: true + +... diff --git a/Documentation/devicetree/bindings/display/rockchip/rockchip,inno-hdmi.yaml b/Documentation/devicetree/bindings/display/rockchip/rockchip,inno-hdmi.yaml index 5b87b0f1963e..589dedfcbee0 100644 --- a/Documentation/devicetree/bindings/display/rockchip/rockchip,inno-hdmi.yaml +++ b/Documentation/devicetree/bindings/display/rockchip/rockchip,inno-hdmi.yaml @@ -16,12 +16,6 @@ properties: - rockchip,rk3036-inno-hdmi - rockchip,rk3128-inno-hdmi - reg: -maxItems: 1 - - interrupts: -maxItems: 1 - clocks: minItems: 1 items: @@ -40,24 +34,6 @@ properties: "#sound-dai-cells": const: 0 - ports: -$ref: /schemas/graph.yaml#/properties/ports - -properties: - port@0: -$ref: /schemas/graph.yaml#/properties/port -description: - Port node with one endpoint connected to a vop node. - - port@1: -$ref: /schemas/graph.yaml#/properties/port -description: - Port node with one endpoint connected to a hdmi-connector node. - -required: - - port@0 - - port@1 - required: - compatible - reg @@ -69,6 +45,7 @@ required: - ports allOf: + - $ref: ../bridge/innosilicon,inno-hdmi.yaml# - $ref: /schemas/sound/dai-common.yaml# - if: properties: @@ -95,7 +72,7 @@ allOf: required: - power-domains -additionalProperties: false +unevaluatedProperties: false examples: - | diff --git a/Documentation/devicetree/bindings/display/starfive/starfive,jh7110-dc8200.yaml b/Documentation/devicetree/bindings/display/starfive/starfive,jh7110-dc8200.yaml new file mode 100644 index ..5f57c405e857 --- /dev/null +++ b/Documentation/devicetree/bindings/display/starfive/starfive,jh7110-dc8200.yaml @@ -0,0 +1,176 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/starfive/starfive,jh7110-dc8200.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Starfive JH7110 SoC Display Controller (DC8200) + +description: + The STARFIVE JH7110 SoC uses the display controller based on Verisilicon + IP(DC8200) to transfer the image data from a video memory buffer to an + external LCD interface. + + pipe0 binds HDMI for primary display, + pipe
[PATCH v5 5/9] drm/vs: Add Base API for VS Mode Configuration
This commit adds a base API for configuring VS modes, which will streamline the setup and management of display modes in the VS DRM subsystem. In this implementation, we are using drm_atomic_helper_commit_tail_rpm() instead of drm_atomic_helper_commit_tail() to ensure that we skip planes related to inactive CRTCs. This helps to optimize the commit process and reduces unnecessary overhead when dealing with inactive display resources. Signed-off-by: keith zhao --- drivers/gpu/drm/verisilicon/Makefile | 3 ++- drivers/gpu/drm/verisilicon/vs_modeset.c | 31 drivers/gpu/drm/verisilicon/vs_modeset.h | 10 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/verisilicon/vs_modeset.c create mode 100644 drivers/gpu/drm/verisilicon/vs_modeset.h diff --git a/drivers/gpu/drm/verisilicon/Makefile b/drivers/gpu/drm/verisilicon/Makefile index 7da54b259940..842867dad4cb 100644 --- a/drivers/gpu/drm/verisilicon/Makefile +++ b/drivers/gpu/drm/verisilicon/Makefile @@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 -vs_drm-objs := vs_dc_hw.o +vs_drm-objs := vs_dc_hw.o \ + vs_modeset.o obj-$(CONFIG_DRM_VERISILICON_DC8200) += vs_drm.o diff --git a/drivers/gpu/drm/verisilicon/vs_modeset.c b/drivers/gpu/drm/verisilicon/vs_modeset.c new file mode 100644 index ..0873a3465143 --- /dev/null +++ b/drivers/gpu/drm/verisilicon/vs_modeset.c @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) VeriSilicon Holdings Co., Ltd. + */ +#include +#include +#include + +#include "vs_modeset.h" + +static const struct drm_mode_config_funcs vs_mode_config_funcs = { + .fb_create = drm_gem_fb_create, + .atomic_check= drm_atomic_helper_check, + .atomic_commit = drm_atomic_helper_commit, +}; + +static struct drm_mode_config_helper_funcs vs_mode_config_helpers = { + .atomic_commit_tail = drm_atomic_helper_commit_tail_rpm, +}; + +void vs_mode_config_init(struct drm_device *dev) +{ + int ret; + + ret = drmm_mode_config_init(dev); + if (ret) + return; + + dev->mode_config.funcs = &vs_mode_config_funcs; + dev->mode_config.helper_private = &vs_mode_config_helpers; +} diff --git a/drivers/gpu/drm/verisilicon/vs_modeset.h b/drivers/gpu/drm/verisilicon/vs_modeset.h new file mode 100644 index ..bd04f81d2ad2 --- /dev/null +++ b/drivers/gpu/drm/verisilicon/vs_modeset.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2020 VeriSilicon Holdings Co., Ltd. + */ + +#ifndef __VS_MODESET_H__ +#define __VS_MODESET_H__ + +void vs_mode_config_init(struct drm_device *dev); +#endif /* __VS_FB_H__ */ -- 2.34.1
[PATCH v5 3/9] drm: bridge: inno-hdmi: add inno bridge driver.
move rochchip inno hdmi connector to a newly created directory named inno-hdmi.c, and rename rockchip/inno_hdmi.c to rockchip/inno_hdmi-rockchip.c This patch refines the Innosilicon HDMI architecture by abstracting the existing connector into a bridge architecture. The drm_bridge_connector_init function is used to create the connector. Signed-off-by: keith zhao --- MAINTAINERS |2 + drivers/gpu/drm/bridge/Kconfig|2 + drivers/gpu/drm/bridge/Makefile |1 + drivers/gpu/drm/bridge/innosilicon/Kconfig|6 + drivers/gpu/drm/bridge/innosilicon/Makefile |2 + .../gpu/drm/bridge/innosilicon/inno-hdmi.c| 376 ++ .../gpu/drm/bridge/innosilicon/inno-hdmi.h| 34 + drivers/gpu/drm/rockchip/Kconfig |1 + drivers/gpu/drm/rockchip/Makefile |2 +- drivers/gpu/drm/rockchip/inno_hdmi-rockchip.c | 690 +++ .../{inno_hdmi.h => inno_hdmi-rockchip.h} |0 drivers/gpu/drm/rockchip/inno_hdmi.c | 1025 - include/drm/bridge/inno_hdmi.h| 56 + 13 files changed, 1171 insertions(+), 1026 deletions(-) create mode 100644 drivers/gpu/drm/bridge/innosilicon/Kconfig create mode 100644 drivers/gpu/drm/bridge/innosilicon/Makefile create mode 100644 drivers/gpu/drm/bridge/innosilicon/inno-hdmi.c create mode 100644 drivers/gpu/drm/bridge/innosilicon/inno-hdmi.h create mode 100644 drivers/gpu/drm/rockchip/inno_hdmi-rockchip.c rename drivers/gpu/drm/rockchip/{inno_hdmi.h => inno_hdmi-rockchip.h} (100%) delete mode 100644 drivers/gpu/drm/rockchip/inno_hdmi.c create mode 100644 include/drm/bridge/inno_hdmi.h diff --git a/MAINTAINERS b/MAINTAINERS index f787dd625497..7766ee0bdd74 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7439,6 +7439,8 @@ S:Maintained T: git https://gitlab.freedesktop.org/drm/misc/kernel.git F: Documentation/devicetree/bindings/display/bridge/innosilicon,inno-hdmi.yaml F: Documentation/devicetree/bindings/display/starfive/ +F: drivers/gpu/drm/bridge/innosilicon/ +F: include/drm/bridge/inno_hdmi.h DRM DRIVER FOR SYNAPTICS R63353 PANELS M: Michael Trimarchi diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig index 683cb33805b2..37be5dd5213f 100644 --- a/drivers/gpu/drm/bridge/Kconfig +++ b/drivers/gpu/drm/bridge/Kconfig @@ -423,6 +423,8 @@ source "drivers/gpu/drm/bridge/cadence/Kconfig" source "drivers/gpu/drm/bridge/imx/Kconfig" +source "drivers/gpu/drm/bridge/innosilicon/Kconfig" + source "drivers/gpu/drm/bridge/synopsys/Kconfig" endmenu diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile index 3daf803ce80b..866d1e0fd8aa 100644 --- a/drivers/gpu/drm/bridge/Makefile +++ b/drivers/gpu/drm/bridge/Makefile @@ -41,4 +41,5 @@ obj-$(CONFIG_DRM_ITE_IT66121) += ite-it66121.o obj-y += analogix/ obj-y += cadence/ obj-y += imx/ +obj-y += innosilicon/ obj-y += synopsys/ diff --git a/drivers/gpu/drm/bridge/innosilicon/Kconfig b/drivers/gpu/drm/bridge/innosilicon/Kconfig new file mode 100644 index ..73dbed3b1c4d --- /dev/null +++ b/drivers/gpu/drm/bridge/innosilicon/Kconfig @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-only +config DRM_INNO_HDMI + tristate + help + Support the common interface which is part of the INNO + Designware HDMI block. diff --git a/drivers/gpu/drm/bridge/innosilicon/Makefile b/drivers/gpu/drm/bridge/innosilicon/Makefile new file mode 100644 index ..3b3a961ab9fb --- /dev/null +++ b/drivers/gpu/drm/bridge/innosilicon/Makefile @@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0-only +obj-$(CONFIG_DRM_INNO_HDMI) += inno-hdmi.o diff --git a/drivers/gpu/drm/bridge/innosilicon/inno-hdmi.c b/drivers/gpu/drm/bridge/innosilicon/inno-hdmi.c new file mode 100644 index ..c26132b41bdf --- /dev/null +++ b/drivers/gpu/drm/bridge/innosilicon/inno-hdmi.c @@ -0,0 +1,376 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) Fuzhou Rockchip Electronics Co.Ltd + *Zheng Yang + *Yakir Yang + * Copyright (C) StarFive Technology Co., Ltd. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "inno-hdmi.h" + +u8 hdmi_readb(struct inno_hdmi *hdmi, u16 offset) +{ + return readl_relaxed(hdmi->regs + (offset) * 0x04); +} +EXPORT_SYMBOL_GPL(hdmi_readb); + +void hdmi_writeb(struct inno_hdmi *hdmi, u16 offset, u32 val) +{ + writel_relaxed(val, hdmi->regs + (offset) * 0x04); +} +EXPORT_SYMBOL_GPL(hdmi_writeb); + +void hdmi_modb(struct inno_hdmi *hdmi, u16 offset, u32 msk, u32 val) +{ + u8 temp = hdmi_readb(hdmi, offset) & ~msk; + + temp |= val & msk; + hdmi_writeb(hdmi, offset, temp); +} +EXPORT_SY
[PATCH v5 8/9] drm/vs: Add Innosilicon HDMI Support
This commit adds the Innosilicon HDMI driver, designed to interface with the VS display controller. The driver leverages the APIs provided by the Innosilicon HDMI bridge. Signed-off-by: keith zhao --- drivers/gpu/drm/verisilicon/Kconfig | 19 + drivers/gpu/drm/verisilicon/Makefile | 1 + .../gpu/drm/verisilicon/inno_hdmi-starfive.c | 553 ++ .../gpu/drm/verisilicon/inno_hdmi-starfive.h | 194 ++ 4 files changed, 767 insertions(+) create mode 100644 drivers/gpu/drm/verisilicon/inno_hdmi-starfive.c create mode 100644 drivers/gpu/drm/verisilicon/inno_hdmi-starfive.h diff --git a/drivers/gpu/drm/verisilicon/Kconfig b/drivers/gpu/drm/verisilicon/Kconfig index 874e8bcde5d5..49648a3a6deb 100644 --- a/drivers/gpu/drm/verisilicon/Kconfig +++ b/drivers/gpu/drm/verisilicon/Kconfig @@ -11,3 +11,22 @@ config DRM_VERISILICON_DC8200 This driver provides VeriSilicon kernel mode setting and buffer management. It does not provide 2D or 3D acceleration. + +config DRM_INNO_STARFIVE_HDMI + bool "Starfive JH7110 specific extensions for Innosilicon HDMI" + depends on DRM_VERISILICON_DC8200 + select DRM_INNO_HDMI + select DRM_DISPLAY_HELPER + select DRM_BRIDGE_CONNECTOR + help + This configuration option enables support for StarFive SoC + specific extensions for the Innosilicon HDMI driver. + + Enabling this option is essential for proper functionality + of HDMI on JH7110 based SoCs. If you are using a StarFive + JH7110 SoC and require HDMI output functionalities, + you should select this option to ensure that the driver is + compiled with the necessary extensions and dependencies. + + This option may enable additional features and capabilities + specific to StarFive's implementation of the HDMI technology. diff --git a/drivers/gpu/drm/verisilicon/Makefile b/drivers/gpu/drm/verisilicon/Makefile index 1a0e46f38ae8..a602630c2416 100644 --- a/drivers/gpu/drm/verisilicon/Makefile +++ b/drivers/gpu/drm/verisilicon/Makefile @@ -5,4 +5,5 @@ vs_drm-objs := vs_dc_hw.o \ vs_crtc.o \ vs_plane.o +vs_drm-$(CONFIG_DRM_INNO_STARFIVE_HDMI) += inno_hdmi-starfive.o obj-$(CONFIG_DRM_VERISILICON_DC8200) += vs_drm.o diff --git a/drivers/gpu/drm/verisilicon/inno_hdmi-starfive.c b/drivers/gpu/drm/verisilicon/inno_hdmi-starfive.c new file mode 100644 index ..6923f789bcc0 --- /dev/null +++ b/drivers/gpu/drm/verisilicon/inno_hdmi-starfive.c @@ -0,0 +1,553 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) StarFive Technology Co., Ltd. + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "inno_hdmi-starfive.h" +#include "vs_crtc.h" + +enum hdmi_clk { + CLK_SYS = 0, + CLK_M, + CLK_B, + CLK_HDMI_NUM +}; + +struct pre_pll_config { + unsigned long pixclock; + unsigned long tmdsclock; + u8 prediv; + u16 fbdiv; + u8 tmds_div_a; + u8 tmds_div_b; + u8 tmds_div_c; + u8 pclk_div_a; + u8 pclk_div_b; + u8 pclk_div_c; + u8 pclk_div_d; + u8 vco_div_5_en; + u32 fracdiv; +}; + +struct post_pll_config { + unsigned long tmdsclock; + u8 prediv; + u16 fbdiv; + u8 postdiv; + u8 post_div_en; + u8 version; +}; + +struct stf_inno_hdmi { + struct drm_encoder encoder; + struct drm_connector*connector; + struct inno_hdmi inno_hdmi; + struct clk_bulk_data clk_hdmi[CLK_HDMI_NUM]; + struct reset_control *tx_rst; + int nclks; + unsigned long tmds_rate; + struct pre_pll_config pre_cfg; + const struct post_pll_config *post_cfg; +}; + +static inline struct stf_inno_hdmi *to_starfive_inno_hdmi(struct drm_encoder *encoder) +{ + return container_of(encoder, struct stf_inno_hdmi, encoder); +} + +static struct inno_hdmi *encoder_to_inno_hdmi(struct drm_encoder *encoder) +{ + struct stf_inno_hdmi *stf_hdmi = to_starfive_inno_hdmi(encoder); + + return &stf_hdmi->inno_hdmi; +} + +static const struct post_pll_config post_pll_cfg_table[] = { + {2520, 1, 80, 13, 3, 1}, + {2700, 1, 40, 11, 3, 1}, + {3375, 1, 40, 11, 3, 1}, + {4900, 1, 20, 1, 3, 3}, + {24170, 1, 20, 1, 3, 3}, + {29700, 4, 20, 0, 0, 3}, + { /* sentinel */ } +}; + +static int inno_hdmi_starfive_enable_clk_rst(struct device *dev, +struct stf_inno_hdmi *stf_inno_hdmi) +{ + int ret; + + ret = clk_bulk_prepare_enable(stf_inno_hdmi->nclks, stf_inno_hdmi->clk_hdmi); + if (ret) { + dev_err(dev, "failed to enable clocks\n&q
[PATCH v5 9/9] drm/vs: Add VS DRM Master Driver for JH7110 SoC
The VS DRM master driver for the JH7110 System on Chip (SoC), along with the addition of a DMA GEM (Graphics Execution Manager) driver Signed-off-by: keith zhao --- drivers/gpu/drm/verisilicon/Makefile | 3 +- drivers/gpu/drm/verisilicon/vs_drv.c | 777 +++ 2 files changed, 779 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/verisilicon/vs_drv.c diff --git a/drivers/gpu/drm/verisilicon/Makefile b/drivers/gpu/drm/verisilicon/Makefile index a602630c2416..67c94518d810 100644 --- a/drivers/gpu/drm/verisilicon/Makefile +++ b/drivers/gpu/drm/verisilicon/Makefile @@ -3,7 +3,8 @@ vs_drm-objs := vs_dc_hw.o \ vs_modeset.o \ vs_crtc.o \ - vs_plane.o + vs_plane.o \ + vs_drv.o vs_drm-$(CONFIG_DRM_INNO_STARFIVE_HDMI) += inno_hdmi-starfive.o obj-$(CONFIG_DRM_VERISILICON_DC8200) += vs_drm.o diff --git a/drivers/gpu/drm/verisilicon/vs_drv.c b/drivers/gpu/drm/verisilicon/vs_drv.c new file mode 100644 index ..830dd0b1e9a0 --- /dev/null +++ b/drivers/gpu/drm/verisilicon/vs_drv.c @@ -0,0 +1,777 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) VeriSilicon Holdings Co., Ltd. + */ +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "vs_drv.h" +#include "vs_crtc.h" +#include "vs_plane.h" +#include "vs_modeset.h" + +#define DRV_NAME "verisilicon" +#define DRV_DESC "Verisilicon DRM driver" +#define DRV_DATE "20230516" +#define DRV_MAJOR 1 +#define DRV_MINOR 0 + +#define FRAC_16_16(mult, div) (((mult) << 16) / (div)) + +static const u32 primary_overlay_format[] = { + DRM_FORMAT_RGB565, + DRM_FORMAT_BGR565, + DRM_FORMAT_XRGB, + DRM_FORMAT_XBGR, + DRM_FORMAT_RGBX, + DRM_FORMAT_BGRX, + DRM_FORMAT_ARGB, + DRM_FORMAT_ABGR, + DRM_FORMAT_RGBA, + DRM_FORMAT_BGRA, + DRM_FORMAT_XRGB, + DRM_FORMAT_XBGR, + DRM_FORMAT_RGBX, + DRM_FORMAT_BGRX, + DRM_FORMAT_ARGB, + DRM_FORMAT_ABGR, + DRM_FORMAT_RGBA, + DRM_FORMAT_BGRA, + DRM_FORMAT_XRGB1555, + DRM_FORMAT_XBGR1555, + DRM_FORMAT_RGBX5551, + DRM_FORMAT_BGRX5551, + DRM_FORMAT_ARGB1555, + DRM_FORMAT_ABGR1555, + DRM_FORMAT_RGBA5551, + DRM_FORMAT_BGRA5551, + DRM_FORMAT_ARGB2101010, + DRM_FORMAT_ABGR2101010, + DRM_FORMAT_RGBA1010102, + DRM_FORMAT_BGRA1010102, + DRM_FORMAT_YUYV, + DRM_FORMAT_YVYU, + DRM_FORMAT_UYVY, + DRM_FORMAT_VYUY, + DRM_FORMAT_YVU420, + DRM_FORMAT_YUV420, + DRM_FORMAT_NV12, + DRM_FORMAT_NV21, + DRM_FORMAT_NV16, + DRM_FORMAT_NV61, + DRM_FORMAT_P010, +}; + +static const u32 cursor_formats[] = { + DRM_FORMAT_ARGB +}; + +static const u64 format_modifier[] = { + DRM_FORMAT_MOD_LINEAR, + DRM_FORMAT_MOD_INVALID +}; + +static const u64 secondary_format_modifiers[] = { + DRM_FORMAT_MOD_LINEAR, + DRM_FORMAT_MOD_INVALID +}; + +static const struct vs_plane_data vs_plane_pri0 = { + .num_formats= ARRAY_SIZE(primary_overlay_format), + .formats= primary_overlay_format, + .num_modifiers = ARRAY_SIZE(format_modifier), + .modifiers = format_modifier, + .min_width = 0, + .min_height = 0, + .max_width = 4096, + .max_height = 4096, + .min_scale = FRAC_16_16(1, 3), + .max_scale = FRAC_16_16(10, 1), + .rotation = DRM_MODE_ROTATE_0 | + DRM_MODE_ROTATE_90 | + DRM_MODE_ROTATE_180 | + DRM_MODE_ROTATE_270 | + DRM_MODE_REFLECT_X | + DRM_MODE_REFLECT_Y, + .color_encoding = BIT(DRM_COLOR_YCBCR_BT709) | BIT(DRM_COLOR_YCBCR_BT2020), + .zpos = 0, +}; + +static const struct vs_plane_data vs_plane_pri1 = { + .num_formats= ARRAY_SIZE(primary_overlay_format), + .formats= primary_overlay_format, + .num_modifiers = ARRAY_SIZE(format_modifier), + .modifiers = format_modifier, + .min_width = 0, + .min_height = 0, + .max_width = 4096, + .max_height
[PATCH v5 2/9] riscv: dts: Add display property
Add the display DT nodes in Starfive JH7110 soc-specific DT file. Signed-off-by: keith zhao --- .../boot/dts/starfive/jh7110-common.dtsi | 125 ++ arch/riscv/boot/dts/starfive/jh7110.dtsi | 41 ++ 2 files changed, 166 insertions(+) diff --git a/arch/riscv/boot/dts/starfive/jh7110-common.dtsi b/arch/riscv/boot/dts/starfive/jh7110-common.dtsi index 9d77713f5361..301b56f2ef0c 100644 --- a/arch/riscv/boot/dts/starfive/jh7110-common.dtsi +++ b/arch/riscv/boot/dts/starfive/jh7110-common.dtsi @@ -30,6 +30,25 @@ memory@4000 { reg = <0x0 0x4000 0x1 0x0>; }; + reserved-memory { + #address-cells = <2>; + #size-cells = <2>; + ranges; + + /* vout applies for space from this CMA +* Without this CMA reservation, +* vout may not work properly. +*/ + linux,cma { + compatible = "shared-dma-pool"; + reusable; + size = <0x0 0x2000>; + alignment = <0x0 0x1000>; + alloc-ranges = <0x0 0x7000 0x0 0x2000>; + linux,cma-default; + }; + }; + gpio-restart { compatible = "gpio-restart"; gpios = <&sysgpio 35 GPIO_ACTIVE_HIGH>; @@ -62,12 +81,55 @@ codec { }; }; }; + + hdmi_con: hdmi-con { + compatible = "hdmi-connector"; + type = "a"; + + port { + hdmi_con_in: endpoint { + remote-endpoint = <&hdmi_out_con>; + }; + }; + }; }; &cpus { timebase-frequency = <400>; }; +&dc8200 { + status = "okay"; + crtc_out: ports { + #address-cells = <1>; + #size-cells = <0>; + + dc_out0: port@0 { + reg = <0>; + #address-cells = <1>; + #size-cells = <0>; + + dc_out_dpi0: endpoint@0 { + reg = <0>; + remote-endpoint = <&hdmi_enc>; + }; + + }; + + dc_out1: port@1 { + reg = <1>; + #address-cells = <1>; + #size-cells = <0>; + + dc_out_dpi1: endpoint@1 { + reg = <1>; + //remote-endpoint = <&dsi_enc>; + }; + + }; + }; +}; + &dvp_clk { clock-frequency = <7425>; }; @@ -88,6 +150,31 @@ &gmac1_rmii_refin { clock-frequency = <5000>; }; +&hdmi { + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <&hdmi_pins>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + hdmi_in: port@0 { + reg = <0>; + hdmi_enc: endpoint { + remote-endpoint = <&dc_out_dpi0>; + }; + }; + + hdmi_out: port@1 { + reg = <1>; + hdmi_out_con: endpoint { + remote-endpoint = <&hdmi_con_in>; + }; + }; + }; +}; + &hdmitx0_pixelclk { clock-frequency = <29700>; }; @@ -366,6 +453,40 @@ &syscrg { }; &sysgpio { + hdmi_pins: hdmi-0 { + hdmi-cec-pins { + pinmux = ; + input-enable; + bias-pull-up; + }; + + hdmi-hpd-pins { + pinmux = ; + input-enable; + bias-disable; /* external pull-up */ + }; + + hdmi-scl-pins { + pinmux = ; + input-enable; + bias-pull-up; + }; + + hdmi-sda-pins { + pinmux = ; + input-enable; + bias-pull-up; + }; + }; + i2c0_pins: i2c0-0 { i2c-pins { pinmux = ; }; + +&voutcrg { + status = "okay"; +}; diff --git a/arch/riscv/boot/dts/starfive/jh7110.dtsi b/arch/riscv/boot/dts/starfive/jh7110.dtsi index 0d8339357bad..d4882
[PATCH v5 7/9] drm/vs: Add VS Plane API
This commit introduces plane functions and helper functions for the VS DRM subsystem, enhancing support for managing display planes and their configurations. Signed-off-by: keith zhao --- drivers/gpu/drm/verisilicon/Makefile | 3 +- drivers/gpu/drm/verisilicon/vs_plane.c | 358 + drivers/gpu/drm/verisilicon/vs_plane.h | 27 ++ 3 files changed, 387 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/verisilicon/vs_plane.c create mode 100644 drivers/gpu/drm/verisilicon/vs_plane.h diff --git a/drivers/gpu/drm/verisilicon/Makefile b/drivers/gpu/drm/verisilicon/Makefile index 37f6a4db2a12..1a0e46f38ae8 100644 --- a/drivers/gpu/drm/verisilicon/Makefile +++ b/drivers/gpu/drm/verisilicon/Makefile @@ -2,6 +2,7 @@ vs_drm-objs := vs_dc_hw.o \ vs_modeset.o \ - vs_crtc.o + vs_crtc.o \ + vs_plane.o obj-$(CONFIG_DRM_VERISILICON_DC8200) += vs_drm.o diff --git a/drivers/gpu/drm/verisilicon/vs_plane.c b/drivers/gpu/drm/verisilicon/vs_plane.c new file mode 100644 index ..ba47d0185fc6 --- /dev/null +++ b/drivers/gpu/drm/verisilicon/vs_plane.c @@ -0,0 +1,358 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) VeriSilicon Holdings Co., Ltd. + */ +#include +#include +#include +#include +#include +#include +#include + +#include "vs_plane.h" +#include "vs_drv.h" +#include "vs_crtc.h" + +static inline struct vs_plane_state * +to_vs_plane_state(struct drm_plane_state *state) +{ + return container_of(state, struct vs_plane_state, base); +} + +static inline struct vs_plane *to_vs_plane(struct drm_plane *plane) +{ + return container_of(plane, struct vs_plane, base); +} + +static void vs_plane_atomic_destroy_state(struct drm_plane *plane, + struct drm_plane_state *state) +{ + struct vs_plane_state *vs_plane_state = to_vs_plane_state(state); + + __drm_atomic_helper_plane_destroy_state(state); + kfree(vs_plane_state); +} + +static void vs_plane_reset(struct drm_plane *plane) +{ + struct vs_plane_state *state; + + if (plane->state) + vs_plane_atomic_destroy_state(plane, plane->state); + + state = kzalloc(sizeof(*state), GFP_KERNEL); + if (!state) + return; + + __drm_atomic_helper_plane_reset(plane, &state->base); +} + +static struct drm_plane_state * +vs_plane_atomic_duplicate_state(struct drm_plane *plane) +{ + struct vs_plane_state *state; + + if (WARN_ON(!plane->state)) + return NULL; + + state = kzalloc(sizeof(*state), GFP_KERNEL); + if (!state) + return NULL; + + __drm_atomic_helper_plane_duplicate_state(plane, &state->base); + + return &state->base; +} + +static bool vs_format_mod_supported(struct drm_plane *plane, + u32 format, + u64 modifier) +{ + int i; + + /* We always have to allow these modifiers: +* 1. Core DRM checks for LINEAR support if userspace does not provide modifiers. +* 2. Not passing any modifiers is the same as explicitly passing INVALID. +*/ + if (modifier == DRM_FORMAT_MOD_LINEAR) + return true; + + /* Check that the modifier is on the list of the plane's supported modifiers. */ + for (i = 0; i < plane->modifier_count; i++) { + if (modifier == plane->modifiers[i]) + break; + } + + if (i == plane->modifier_count) + return false; + + return true; +} + +static const struct drm_plane_funcs vs_plane_funcs = { + .update_plane = drm_atomic_helper_update_plane, + .disable_plane = drm_atomic_helper_disable_plane, + .reset = vs_plane_reset, + .atomic_duplicate_state = vs_plane_atomic_duplicate_state, + .atomic_destroy_state = vs_plane_atomic_destroy_state, + .format_mod_supported = vs_format_mod_supported, +}; + +static unsigned char vs_get_plane_number(struct drm_framebuffer *fb) +{ + const struct drm_format_info *info; + + if (!fb) + return 0; + + info = drm_format_info(fb->format->format); + if (!info || info->num_planes > DRM_FORMAT_MAX_PLANES) + return 0; + + return info->num_planes; +} + +static bool vs_dc_mod_supported(const struct vs_plane_info *vs_info, u64 modifier) +{ + const u64 *mods; + + if (vs_info->type == DRM_PLANE_TYPE_CURSOR) + return 0; + + if (!vs_info->data->modifiers) + return false; + + for (mods = vs_info->data->modifiers; *mods != DRM_FORMAT_MOD_INVALID; mods++) { + if (*mods == modifier) + return true; + } + + return fa
[PATCH v5 6/9] drm/vs: Add CRTC Functions
This commit adds CRTC functions and helper functions to the VS DRM subsystem, enhancing support for display management and configurations. Signed-off-by: keith zhao --- drivers/gpu/drm/verisilicon/Makefile | 3 +- drivers/gpu/drm/verisilicon/vs_crtc.c | 241 ++ drivers/gpu/drm/verisilicon/vs_crtc.h | 42 + drivers/gpu/drm/verisilicon/vs_drv.h | 41 + 4 files changed, 326 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/verisilicon/vs_crtc.c create mode 100644 drivers/gpu/drm/verisilicon/vs_crtc.h create mode 100644 drivers/gpu/drm/verisilicon/vs_drv.h diff --git a/drivers/gpu/drm/verisilicon/Makefile b/drivers/gpu/drm/verisilicon/Makefile index 842867dad4cb..37f6a4db2a12 100644 --- a/drivers/gpu/drm/verisilicon/Makefile +++ b/drivers/gpu/drm/verisilicon/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 vs_drm-objs := vs_dc_hw.o \ - vs_modeset.o + vs_modeset.o \ + vs_crtc.o obj-$(CONFIG_DRM_VERISILICON_DC8200) += vs_drm.o diff --git a/drivers/gpu/drm/verisilicon/vs_crtc.c b/drivers/gpu/drm/verisilicon/vs_crtc.c new file mode 100644 index ..45ce28960e27 --- /dev/null +++ b/drivers/gpu/drm/verisilicon/vs_crtc.c @@ -0,0 +1,241 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) VeriSilicon Holdings Co., Ltd. + * + */ +#include +#include +#include +#include + +#include "vs_crtc.h" +#include "vs_drv.h" + +static void vs_crtc_atomic_destroy_state(struct drm_crtc *crtc, +struct drm_crtc_state *state) +{ + __drm_atomic_helper_crtc_destroy_state(state); + kfree(to_vs_crtc_state(state)); +} + +static void vs_crtc_reset(struct drm_crtc *crtc) +{ + struct vs_crtc_state *state; + + if (crtc->state) + vs_crtc_atomic_destroy_state(crtc, crtc->state); + + state = kzalloc(sizeof(*state), GFP_KERNEL); + if (!state) + return; + + __drm_atomic_helper_crtc_reset(crtc, &state->base); +} + +static struct drm_crtc_state * +vs_crtc_atomic_duplicate_state(struct drm_crtc *crtc) +{ + struct vs_crtc_state *old_state; + struct vs_crtc_state *state; + + if (!crtc->state) + return NULL; + + old_state = to_vs_crtc_state(crtc->state); + + state = kmemdup(old_state, sizeof(*old_state), GFP_KERNEL); + if (!state) + return NULL; + + __drm_atomic_helper_crtc_duplicate_state(crtc, &state->base); + + return &state->base; +} + +static int vs_crtc_enable_vblank(struct drm_crtc *crtc) +{ + struct vs_drm_device *priv = to_vs_drm_private(crtc->dev); + struct vs_dc *dc = &priv->dc; + + dc_hw_enable_interrupt(&dc->hw); + + return 0; +} + +static void vs_crtc_disable_vblank(struct drm_crtc *crtc) +{ + struct vs_drm_device *priv = to_vs_drm_private(crtc->dev); + struct vs_dc *dc = &priv->dc; + + dc_hw_disable_interrupt(&dc->hw); +} + +static const struct drm_crtc_funcs vs_crtc_funcs = { + .set_config = drm_atomic_helper_set_config, + .page_flip = drm_atomic_helper_page_flip, + .reset = vs_crtc_reset, + .atomic_duplicate_state = vs_crtc_atomic_duplicate_state, + .atomic_destroy_state = vs_crtc_atomic_destroy_state, + .enable_vblank = vs_crtc_enable_vblank, + .disable_vblank = vs_crtc_disable_vblank, +}; + +static void vs_crtc_atomic_enable(struct drm_crtc *crtc, + struct drm_atomic_state *state) +{ + struct vs_drm_device *priv = to_vs_drm_private(crtc->dev); + struct vs_dc *dc = &priv->dc; + + struct vs_crtc_state *crtc_state = to_vs_crtc_state(crtc->state); + struct drm_display_mode *mode = &crtc->state->adjusted_mode; + int id; + + id = to_vs_display_id(crtc); + if (crtc_state->encoder_type == DRM_MODE_ENCODER_DSI) { + dc_hw_set_out(&dc->hw, OUT_DPI, id); + clk_set_rate(priv->clks[7].clk, mode->clock * 1000); + clk_set_parent(priv->clks[5].clk, priv->clks[7].clk); + } else { + dc_hw_set_out(&dc->hw, OUT_DP, id); + clk_set_parent(priv->clks[4].clk, priv->clks[6].clk); + } + + dc_hw_enable(&dc->hw, id, mode, crtc_state->encoder_type, crtc_state->output_fmt); + + enable_irq(priv->irq); + + drm_crtc_vblank_on(crtc); +} + +static void vs_crtc_atomic_disable(struct drm_crtc *crtc, + struct drm_atomic_state *state) +{ + struct vs_drm_device *priv = to_vs_drm_private(crtc->dev); + struct vs_dc *dc = &priv->dc; + int id; + + drm_crtc_vblank_off(crtc); + + disable_irq(priv->ir
RE: [PATCH v5 3/9] drm: bridge: inno-hdmi: add inno bridge driver.
> -Original Message- > From: Krzysztof Kozlowski > Sent: 2024年11月20日 15:38 > To: Keith Zhao ; devicet...@vger.kernel.org; > dri-devel@lists.freedesktop.org > Cc: andrzej.ha...@intel.com; neil.armstr...@linaro.org; rf...@kernel.org; > laurent.pinch...@ideasonboard.com; jo...@kwiboo.se; > jernej.skra...@gmail.com; maarten.lankho...@linux.intel.com; > mrip...@kernel.org; tzimmerm...@suse.de; airl...@gmail.com; > sim...@ffwll.ch; r...@kernel.org; krzk...@kernel.org; conor...@kernel.org; > h...@rock-chips.com; he...@sntech.de; andy@rock-chips.com; William Qiu > ; Xingyu Wu ; > ker...@esmil.dk; paul.walms...@sifive.com; pal...@dabbelt.com; > a...@eecs.berkeley.edu; p.za...@pengutronix.de; Changhuang Liang > ; Jack Zhu ; > linux-ker...@vger.kernel.org > Subject: Re: [PATCH v5 3/9] drm: bridge: inno-hdmi: add inno bridge driver. > > On 20/11/2024 07:18, keith zhao wrote: > > + /* Unmute hotplug interrupt */ > > + hdmi_modb(hdmi, HDMI_STATUS, m_MASK_INT_HOTPLUG, > > +v_MASK_INT_HOTPLUG(1)); > > + > > + ret = devm_request_threaded_irq(hdmi->dev, irq, inno_hdmi_hardirq, > > + inno_hdmi_irq, IRQF_SHARED, > > + dev_name(hdmi->dev), hdmi); > > + return ret; > > +} > > +EXPORT_SYMBOL_GPL(inno_hdmi_bind); > > + > > +MODULE_AUTHOR("Keith Zhao "); > > +MODULE_DESCRIPTION("INNO HDMI transmitter driver"); > > +MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:inno-hdmi"); > > You should not need MODULE_ALIAS() in normal cases. If you need it, usually it > means your device ID table is wrong (e.g. misses either entries or > MODULE_DEVICE_TABLE()). MODULE_ALIAS() is not a substitute for incomplete > ID table. > Thank you for your suggestion! I will review the device ID table to ensure its completeness and avoid using MODULE_ALIAS(). > > Best regards, > Krzysztof
RE: [PATCH v5 1/9] dt-bindings: display: bindings for starfive, JH7110 display pipeline
> -Original Message- > From: Krzysztof Kozlowski > Sent: 2024年11月21日 16:23 > To: Keith Zhao > Cc: devicet...@vger.kernel.org; dri-devel@lists.freedesktop.org; > andrzej.ha...@intel.com; neil.armstr...@linaro.org; rf...@kernel.org; > laurent.pinch...@ideasonboard.com; jo...@kwiboo.se; > jernej.skra...@gmail.com; maarten.lankho...@linux.intel.com; > mrip...@kernel.org; tzimmerm...@suse.de; airl...@gmail.com; > sim...@ffwll.ch; r...@kernel.org; krzk...@kernel.org; conor...@kernel.org; > h...@rock-chips.com; he...@sntech.de; andy@rock-chips.com; William Qiu > ; Xingyu Wu ; > ker...@esmil.dk; paul.walms...@sifive.com; pal...@dabbelt.com; > a...@eecs.berkeley.edu; p.za...@pengutronix.de; Changhuang Liang > ; Jack Zhu ; > linux-ker...@vger.kernel.org > Subject: Re: [PATCH v5 1/9] dt-bindings: display: bindings for starfive,JH7110 > display pipeline > > On Wed, Nov 20, 2024 at 02:18:40PM +0800, keith zhao wrote: > > - Added bindings to support the display subsystem on the JH7110 SoC. > > Please do not use "This commit/patch/change" (implied) and past tense, but > imperative mood. See longer explanation here: > https://elixir.bootlin.com/linux/v5.17.1/source/Documentation/process/submitti > ng-patches.rst#L95 > > > > > - Included the DC8200 display controller and Inno HDMI controller. > > > > - Created innosilicon,inno-hdmi.yaml schema containing common properties > > for the Inno DesignWare HDMI TX controller. > > This isn't a full device tree binding specification, > > but is intended to be referenced by platform-specific bindings > > for the IP core. > > > > Signed-off-by: keith zhao > > --- > > .../display/bridge/innosilicon,inno-hdmi.yaml | 45 + > > .../display/rockchip/rockchip,inno-hdmi.yaml | 27 +-- > > .../starfive/starfive,jh7110-dc8200.yaml | 176 ++ > > .../starfive/starfive,jh7110-inno-hdmi.yaml | 91 + > > .../soc/starfive/starfive,jh7110-syscon.yaml | 1 + > > I do not see how you addressed my feedback. I asked you to split the patch. > Where is the split? Oh sorry, I had a bit of a misunderstanding here before. "Your patch is difficult to review. Split changing existing bindings (and defining common part) to a separate patch." .. Split changing existing bindings (and defining common part) to a separate "bindings". ... > > Your answer to my request to split was "Background is ...", yeah, so what? You > are not going to split? > Based on the misunderstanding of this idea, it led to not splitting the patch this time. Now I understand. Will split it . > > > MAINTAINERS | 8 + > > 6 files changed, 323 insertions(+), 25 deletions(-) create mode > > 100644 > > Documentation/devicetree/bindings/display/bridge/innosilicon,inno-hdmi > > .yaml create mode 100644 > > Documentation/devicetree/bindings/display/starfive/starfive,jh7110-dc8 > > 200.yaml create mode 100644 > > Documentation/devicetree/bindings/display/starfive/starfive,jh7110-inn > > o-hdmi.yaml > > > > diff --git > > a/Documentation/devicetree/bindings/display/bridge/innosilicon,inno-hd > > mi.yaml > > b/Documentation/devicetree/bindings/display/bridge/innosilicon,inno-hd > > mi.yaml > > new file mode 100644 > > index ..f2543aebc312 > > --- /dev/null > > +++ b/Documentation/devicetree/bindings/display/bridge/innosilicon,inn > > +++ o-hdmi.yaml > > @@ -0,0 +1,45 @@ > > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) %YAML 1.2 > > +--- > > +$id: > > +http://devicetree.org/schemas/display/bridge/innosilicon,inno-hdmi.ya > > +ml# > > +$schema: http://devicetree.org/meta-schemas/core.yaml# > > + > > +title: Common Properties for Innosilicon HDMI TX IP > > + > > +maintainers: > > + - keith zhao > > + > > +description: | > > Do not need '|' unless you need to preserve formatting. > I will remove the '|' since it's not necessary for preserving formatting. And here is the reason why add '|' before. https://elixir.bootlin.com/linux/v6.12/source/Documentation/devicetree/bindings/display/bridge/synopsys,dw-hdmi.yaml#L12 > > > > + Innosilicon HDMI TX is an HDMI transmission device integrated into the > zap SoC. > > Keep and extend. Ok > > > + This document specifies the device tree properties for the INNO HDMI IP > core. > > Keep... but what is INNO HDMI IP core? Another name? Different block? > > > > + It is intended to be referenced by platform-s