From 0e241e03f2821d26e37dfa39df529a2c4113be1e Mon Sep 17 00:00:00 2001 From: Kiboneu <-> Date: Tue, 22 Apr 2025 01:44:29 -0400 Subject: [PATCH 1/2] Convert to fbdev-ttm (kernel 6.11+) and use drm_format_conv_state (kernel 6.8+) --- src/drm_iface.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/drm_iface.c b/src/drm_iface.c index 8c57910..e62b7e0 100644 --- a/src/drm_iface.c +++ b/src/drm_iface.c @@ -32,7 +32,10 @@ #include #include -#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0) +// https://github.com/torvalds/linux/commit/aae4682e5d66c1e1dc181fa341652e037237f144 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 11, 0) +#include +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0) #include #endif @@ -262,6 +265,11 @@ static int sharp_memory_clip_mono_tagged(struct sharp_memory_panel* panel, size_ struct drm_gem_dma_object *dma_obj; struct iosys_map dst, vmap; + // https://github.com/torvalds/linux/commit/4cd24d4b1a9548f42cdb7f449edc6f869a8ae730 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 8, 0) + struct drm_format_conv_state fmtcnv_state = DRM_FORMAT_CONV_STATE_INIT; +#endif + // Get GEM memory manager dma_obj = drm_fb_dma_get_gem_obj(fb, 0); @@ -274,8 +282,13 @@ static int sharp_memory_clip_mono_tagged(struct sharp_memory_panel* panel, size_ // Initialize destination (buf) and source (video) iosys_map_set_vaddr(&dst, buf); iosys_map_set_vaddr(&vmap, dma_obj->vaddr); + // DMA `clip` into `buf` and convert to 8-bit grayscale +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 8, 0) + drm_fb_xrgb8888_to_gray8(&dst, NULL, &vmap, fb, clip, &fmtcnv_state); +#else drm_fb_xrgb8888_to_gray8(&dst, NULL, &vmap, fb, clip); +#endif // End DMA area drm_gem_fb_end_cpu_access(fb, DMA_FROM_DEVICE); @@ -292,6 +305,9 @@ static int sharp_memory_clip_mono_tagged(struct sharp_memory_panel* panel, size_ (clip->x2 - clip->x1), (clip->y2 - clip->y1), clip->y1); // Success +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 8, 0) + drm_format_conv_state_release(&fmtcnv_state); +#endif return 0; } @@ -598,7 +614,12 @@ int drm_probe(struct spi_device *spi) // fbdev setup spi_set_drvdata(spi, drm); + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 11, 0) + drm_ttm_setup(drm, 0); +#else drm_fbdev_generic_setup(drm, 0); +#endif printk(KERN_INFO "sharp_memory: successful probe\n"); From ea98230f3b1ff9da993c85c8aa958d338bdd1847 Mon Sep 17 00:00:00 2001 From: Kiboneu <-> Date: Tue, 22 Apr 2025 01:48:12 -0400 Subject: [PATCH 2/2] Fix typo: s/drm_ttm_setup/drm_fbdev_ttm_setup --- src/drm_iface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/drm_iface.c b/src/drm_iface.c index e62b7e0..cecd0f9 100644 --- a/src/drm_iface.c +++ b/src/drm_iface.c @@ -616,7 +616,7 @@ int drm_probe(struct spi_device *spi) spi_set_drvdata(spi, drm); #if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 11, 0) - drm_ttm_setup(drm, 0); + drm_fbdev_ttm_setup(drm, 0); #else drm_fbdev_generic_setup(drm, 0); #endif