Color lookup support for the atmel-hlcdc driver
Hi!
I need color lookup support for the atmel-hlcdc driver, and had a peek at the code. I also looked at the drivers/gpu/drm/stm driver and came up with the below diff. It compiles, but I have not booted it for the simple reason that I can't imagine it will work.
Sure, the code fills the clut registers in the .load_lut helper function and I think it might even do the right thing when setting up the mode. I'm less sure DMA will work correctly? It might, but I haven't looked at it for many seconds...
The big question is how the color info gets into the new clut array I created in atmel_hlcdc_crtc? When I look at the stm driver, which does it just like this AFAICT I just don't see it. So, what I'm I missing?
Also, when I'm looking at the docs for .load_lut I get the feeling that I'm barking up some dead old tree.
help
Cheers,
peda
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c +19 -0
@@ -61,6 +61,7 @@ struct atmel_hlcdc_crtc {struct atmel_hlcdc_dc *dc;struct drm_pending_vblank_event *event;int id; +u32 clut[256 ]; }; static inline struct atmel_hlcdc_crtc *
@@ -140,6 +141,23 @@ static void atmel_hlcdc_crtc_mode_set_nofb(struct drm_crtc *c) cfg); } +static void +atmel_hlcdc_crtc_load_lut (struct drm_crtc *c) +{ +struct atmel_hlcdc_crtc *crtc =drm_crtc_to_atmel_hlcdc_crtc (c); +struct atmel_hlcdc_dc *dc = crtc->dc; +unsigned int color; +int layer; + +for (layer =0 ; layer <ATMEL_HLCDC_MAX_LAYERS ; layer++) { +if (!dc->layers[layer]) +continue ; +for (color =0 ; color <256 ; color++) +atmel_hlcdc_layer_write_clut (dc->layers[layer], + color, crtc->clut[color]); + } +} +static enum drm_mode_status atmel_hlcdc_crtc_mode_valid (struct drm_crtc *c,const struct drm_display_mode *mode)
@@ -319,6 +337,7 @@ static const struct drm_crtc_helper_funcs lcdc_crtc_helper_funcs = { .mode_set = drm_helper_crtc_mode_set, .mode_set_nofb = atmel_hlcdc_crtc_mode_set_nofb, .mode_set_base = drm_helper_crtc_mode_set_base, + .load_lut = atmel_hlcdc_crtc_load_lut, .disable = atmel_hlcdc_crtc_disable, .enable = atmel_hlcdc_crtc_enable, .atomic_check = atmel_hlcdc_crtc_atomic_check,
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c +10 -0
@@ -37,6 +37,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_at91sam9n12_layers[] = { .id = 0, .type = ATMEL_HLCDC_BASE_LAYER, .cfgs_offset = 0x2c, + .clut_offset = 0x400, .layout = { .xstride = { 2 }, .default_color = 3,
@@ -66,6 +67,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_at91sam9x5_layers[] = { .id = 0, .type = ATMEL_HLCDC_BASE_LAYER, .cfgs_offset = 0x2c, + .clut_offset = 0x400, .layout = { .xstride = { 2 }, .default_color = 3,
@@ -81,6 +83,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_at91sam9x5_layers[] = { .id = 1, .type = ATMEL_HLCDC_OVERLAY_LAYER, .cfgs_offset = 0x2c, + .clut_offset = 0x800, .layout = { .pos = 2, .size = 3,
@@ -99,6 +102,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_at91sam9x5_layers[] = { .id = 2, .type = ATMEL_HLCDC_OVERLAY_LAYER, .cfgs_offset = 0x4c, + .clut_offset = 0x1000, .layout = { .pos = 2, .size = 3,
@@ -122,6 +126,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_at91sam9x5_layers[] = { .max_width = 128, .max_height = 128, .cfgs_offset = 0x2c, + .clut_offset = 0x1400, .layout = { .pos = 2, .size = 3,
@@ -155,6 +160,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_sama5d3_layers[] = { .id = 0, .type = ATMEL_HLCDC_BASE_LAYER, .cfgs_offset = 0x2c, + .clut_offset = 0x600, .layout = { .xstride = { 2 }, .default_color = 3,
@@ -170,6 +176,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_sama5d3_layers[] = { .id = 1, .type = ATMEL_HLCDC_OVERLAY_LAYER, .cfgs_offset = 0x2c, + .clut_offset = 0xa00, .layout = { .pos = 2, .size = 3,
@@ -188,6 +195,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_sama5d3_layers[] = { .id = 2, .type = ATMEL_HLCDC_OVERLAY_LAYER, .cfgs_offset = 0x2c, + .clut_offset = 0xe00, .layout = { .pos = 2, .size = 3,
@@ -206,6 +214,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_sama5d3_layers[] = { .id = 3, .type = ATMEL_HLCDC_OVERLAY_LAYER, .cfgs_offset = 0x4c, + .clut_offset = 0x1200, .layout = { .pos = 2, .size = 3,
@@ -233,6 +242,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_sama5d3_layers[] = { .max_width = 128, .max_height = 128, .cfgs_offset = 0x2c, + .clut_offset = 0x1600, .layout = { .pos = 2, .size = 3,
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h +14 -0
@@ -88,6 +88,11 @@#define ATMEL_HLCDC_YUV422SWP BIT(17)#define ATMEL_HLCDC_DSCALEOPT BIT(20) +#define ATMEL_HLCDC_C1_MODE ATMEL_HLCDC_CLUT_MODE(0) +#define ATMEL_HLCDC_C2_MODE ATMEL_HLCDC_CLUT_MODE(1) +#define ATMEL_HLCDC_C4_MODE ATMEL_HLCDC_CLUT_MODE(2) +#define ATMEL_HLCDC_C8_MODE ATMEL_HLCDC_CLUT_MODE(3) +#define ATMEL_HLCDC_XRGB4444_MODE ATMEL_HLCDC_RGB_MODE(0)#define ATMEL_HLCDC_ARGB4444_MODE ATMEL_HLCDC_RGB_MODE(1)#define ATMEL_HLCDC_RGBA4444_MODE ATMEL_HLCDC_RGB_MODE(2)
@@ -259,6 +264,7 @@ struct atmel_hlcdc_layer_desc {int id;int regs_offset;int cfgs_offset; +int clut_offset;struct atmel_hlcdc_formats *formats;struct atmel_hlcdc_layer_cfg_layout layout;int max_width;
@@ -414,6 +420,14 @@ static inline u32 atmel_hlcdc_layer_read_cfg(struct atmel_hlcdc_layer *layer, (cfgid * sizeof(u32))); } +static inline void atmel_hlcdc_layer_write_clut (struct atmel_hlcdc_layer *layer, +unsigned int c,u32 val) +{ +atmel_hlcdc_layer_write_reg (layer, + layer->desc->clut_offset + c *sizeof (u32), + val); +} +static inline void atmel_hlcdc_layer_init (struct atmel_hlcdc_layer *layer,const struct atmel_hlcdc_layer_desc *desc,struct regmap *regmap)
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c +5 -0
@@ -83,6 +83,7 @@ drm_plane_state_to_atmel_hlcdc_plane_state(struct drm_plane_state *s)#define SUBPIXEL_MASK 0xffffstatic uint32_t rgb_formats[] = { +DRM_FORMAT_C8 ,DRM_FORMAT_XRGB4444 ,DRM_FORMAT_ARGB4444 ,DRM_FORMAT_RGBA4444 ,
@@ -100,6 +101,7 @@ struct atmel_hlcdc_formats atmel_hlcdc_plane_rgb_formats = { };static uint32_t rgb_and_yuv_formats[] = { +DRM_FORMAT_C8 ,DRM_FORMAT_XRGB4444 ,DRM_FORMAT_ARGB4444 ,DRM_FORMAT_RGBA4444 ,
@@ -128,6 +130,9 @@ struct atmel_hlcdc_formats atmel_hlcdc_plane_rgb_and_yuv_formats = {static int atmel_hlcdc_format_to_plane_mode (u32 format,u32 *mode) {switch (format) { +case DRM_FORMAT_C8 : + *mode =ATMEL_HLCDC_C8_MODE ; +break ;case DRM_FORMAT_XRGB4444 : *mode =ATMEL_HLCDC_XRGB4444_MODE ;break ;
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Hi Peter,
Quoted 7 lines · On Tue, 13 Jun 2017 16:34:25 +0200 Peter Rosin <[email protected]> wrote:
Hi!
I need color lookup support for the atmel-hlcdc driver, and had a peek at the code. I also looked at the
drivers/gpu/drm/stmdriver and came up with the below diff. It compiles, but I have not booted it for the simple reason that I can't imagine it will work.
Quoted 8 lines
Sure, the code fills the clut registers in the .load_lut helper function and I think it might even do the right thing when setting up the mode. I'm less sure DMA will work correctly? It might, but I haven't looked at it for many seconds...
The big question is how the color info gets into the new clut array I created in
atmel_hlcdc_crtc? When I look at the stm driver, which does it just like this AFAICT I just don't see it. So, what I'm I missing?
You should look at drm_atomic_helper_legacy_gamma_set() and its users.
Regards,
Boris
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 17 lines · Boris Brezillon
Hi Peter,
Quoted 12 lines · On Tue, 13 Jun 2017 16:34:25 +0200 Peter Rosin <[email protected]> wrote:
Hi!
I need color lookup support for the atmel-hlcdc driver, and had a peek at the code. I also looked at the
drivers/gpu/drm/stmdriver and came up with the below diff. It compiles, but I have not booted it for the simple reason that I can't imagine it will work.Sure, the code fills the clut registers in the .load_lut helper function and I think it might even do the right thing when setting up the mode. I'm less sure DMA will work correctly? It might, but I haven't looked at it for many seconds...
Quoted 5 lines
Quoted 3 lines
The big question is how the color info gets into the new clut array I created in
atmel_hlcdc_crtc? When I look at the stm driver, which does it just like this AFAICT I just don't see it. So, what I'm I missing?You should look at
drm_atomic_helper_legacy_gamma_set()and its users.
Ok, thanks. I had a long look and could not get it to work at all. So, I did as below instead. However, there are a few glaring problems...
Something, somewhere, sets up default entries for the 16 first entries of the palette and seem to expect them to stay as some kind of safe basic palette, and my applications don't handle it too well. When they want to draw black, they get a poisonous cyan/green instead etc. But it's pretty close. Can anyone provide some clue as to how that is supposed to be handled?
Also, I had to change the second argument of the drm_fbdev_cma_init... call at the end of atmel_hlcdc_dc.c:atmel_hlcdc_dc_load() from 24 to 8 to make it possible to set 8-modes. However, doing so fucks up 24-bit modes. Which made me suspect that no non-24-bit mode work w/o my patch. And I could indeed only get 24-bit modes to work, unless I changed this value to 16. Then RGB565 works like a charm, but RGB888 don't. What's up with that? Seems like a rather silly limitation, but it's perhaps just a bug?
Cheers,
peda
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c +43 -0
@@ -61,6 +61,7 @@ struct atmel_hlcdc_crtc {struct atmel_hlcdc_dc *dc;struct drm_pending_vblank_event *event;int id; +u32 clut[256 ]; }; static inline struct atmel_hlcdc_crtc *
@@ -140,6 +141,47 @@ static void atmel_hlcdc_crtc_mode_set_nofb(struct drm_crtc *c) cfg); } +static void +atmel_hlcdc_crtc_load_lut (struct drm_crtc *c) +{ +struct atmel_hlcdc_crtc *crtc =drm_crtc_to_atmel_hlcdc_crtc (c); +struct atmel_hlcdc_dc *dc = crtc->dc; +unsigned int color; +int layer; + +for (layer =0 ; layer <ATMEL_HLCDC_MAX_LAYERS ; layer++) { +if (!dc->layers[layer]) +continue ; +for (color =0 ; color <256 ; color++) +atmel_hlcdc_layer_write_clut (dc->layers[layer], + color, crtc->clut[color]); + } +} + +void atmel_hlcdc_gamma_set (struct drm_crtc *c, +u16 r,u16 g,u16 b,int idx) +{ +struct atmel_hlcdc_crtc *crtc =drm_crtc_to_atmel_hlcdc_crtc (c); + +if (idx <0 || idx >255 ) +return ; + + crtc->clut[idx] = ((r <<8 ) &0xff0000 ) | (g &0xff00 ) | (b >>8 ); +} + +void atmel_hlcdc_gamma_get (struct drm_crtc *c, +u16 *r,u16 *g,u16 *b,int idx) +{ +struct atmel_hlcdc_crtc *crtc =drm_crtc_to_atmel_hlcdc_crtc (c); + +if (idx <0 || idx >255 ) +return ; + + *r = (crtc->clut[idx] >>8 ) &0xff00 ; + *g = crtc->clut[idx] &0xff00 ; + *b = (crtc->clut[idx] <<8 ) &0xff00 ; +} +static enum drm_mode_status atmel_hlcdc_crtc_mode_valid (struct drm_crtc *c,const struct drm_display_mode *mode)
@@ -319,6 +361,7 @@ static const struct drm_crtc_helper_funcs lcdc_crtc_helper_funcs = { .mode_set = drm_helper_crtc_mode_set, .mode_set_nofb = atmel_hlcdc_crtc_mode_set_nofb, .mode_set_base = drm_helper_crtc_mode_set_base, + .load_lut = atmel_hlcdc_crtc_load_lut, .disable = atmel_hlcdc_crtc_disable, .enable = atmel_hlcdc_crtc_enable, .atomic_check = atmel_hlcdc_crtc_atomic_check,
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c +23 -2
@@ -42,6 +42,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_at91sam9n12_layers[] = { .default_color = 3, .general_config = 4, }, + .clut_offset = 0x400, }, };
@@ -73,6 +74,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_at91sam9x5_layers[] = { .disc_pos = 5, .disc_size = 6, }, + .clut_offset = 0x400, }, { .name = "overlay1",
@@ -91,6 +93,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_at91sam9x5_layers[] = { .chroma_key_mask = 8, .general_config = 9, }, + .clut_offset = 0x800, }, { .name = "high-end-overlay",
@@ -112,6 +115,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_at91sam9x5_layers[] = { .scaler_config = 13, .csc = 14, }, + .clut_offset = 0x1000, }, { .name = "cursor",
@@ -131,6 +135,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_at91sam9x5_layers[] = { .chroma_key_mask = 8, .general_config = 9, }, + .clut_offset = 0x1400, }, };
@@ -162,6 +167,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_sama5d3_layers[] = { .disc_pos = 5, .disc_size = 6, }, + .clut_offset = 0x600, }, { .name = "overlay1",
@@ -180,6 +186,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_sama5d3_layers[] = { .chroma_key_mask = 8, .general_config = 9, }, + .clut_offset = 0xa00, }, { .name = "overlay2",
@@ -198,6 +205,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_sama5d3_layers[] = { .chroma_key_mask = 8, .general_config = 9, }, + .clut_offset = 0xe00, }, { .name = "high-end-overlay",
@@ -223,6 +231,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_sama5d3_layers[] = { }, .csc = 14, }, + .clut_offset = 0x1200, }, { .name = "cursor",
@@ -244,6 +253,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_sama5d3_layers[] = { .general_config = 9, .scaler_config = 13, }, + .clut_offset = 0x1600, }, };
@@ -275,6 +285,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_sama5d4_layers[] = { .disc_pos = 5, .disc_size = 6, }, + .clut_offset = 0x600, }, { .name = "overlay1",
@@ -293,6 +304,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_sama5d4_layers[] = { .chroma_key_mask = 8, .general_config = 9, }, + .clut_offset = 0xa00, }, { .name = "overlay2",
@@ -336,6 +348,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_sama5d4_layers[] = { }, .csc = 14, }, + .clut_offset = 0x1200, }, };
@@ -588,6 +601,12 @@ static int atmel_hlcdc_dc_modeset_init(struct drm_device *dev)return 0 ; } +static const struct drm_fb_helper_funcs atmel_hlcdc_fb_cma_helper_funcs = { + .gamma_set = atmel_hlcdc_gamma_set, + .gamma_get = atmel_hlcdc_gamma_get, + .fb_probe = drm_fbdev_cma_create, +}; +static int atmel_hlcdc_dc_load (struct drm_device *dev) {struct platform_device *pdev =to_platform_device (dev->dev);
@@ -651,8 +670,10 @@ static int atmel_hlcdc_dc_load(struct drm_device *dev)platform_set_drvdata (pdev, dev); - dc->fbdev =drm_fbdev_cma_init (dev,24 , - dev->mode_config.num_connector); + dc->fbdev =drm_fbdev_cma_init_with_funcs2 (dev,8 , + dev->mode_config.num_connector, +NULL , + &atmel_hlcdc_fb_cma_helper_funcs);if (IS_ERR (dc->fbdev)) dc->fbdev =NULL ;
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h +18 -0
@@ -32,6 +32,7 @@#include <drm/drm_atomic_helper.h> #include <drm/drm_crtc.h> #include <drm/drm_crtc_helper.h> +#include <drm/drm_fb_helper.h> #include <drm/drm_fb_cma_helper.h> #include <drm/drm_gem_cma_helper.h> #include <drm/drm_panel.h>
@@ -88,6 +89,11 @@#define ATMEL_HLCDC_YUV422SWP BIT(17)#define ATMEL_HLCDC_DSCALEOPT BIT(20) +#define ATMEL_HLCDC_C1_MODE ATMEL_HLCDC_CLUT_MODE(0) +#define ATMEL_HLCDC_C2_MODE ATMEL_HLCDC_CLUT_MODE(1) +#define ATMEL_HLCDC_C4_MODE ATMEL_HLCDC_CLUT_MODE(2) +#define ATMEL_HLCDC_C8_MODE ATMEL_HLCDC_CLUT_MODE(3) +#define ATMEL_HLCDC_XRGB4444_MODE ATMEL_HLCDC_RGB_MODE(0)#define ATMEL_HLCDC_ARGB4444_MODE ATMEL_HLCDC_RGB_MODE(1)#define ATMEL_HLCDC_RGBA4444_MODE ATMEL_HLCDC_RGB_MODE(2)
@@ -259,6 +265,7 @@ struct atmel_hlcdc_layer_desc {int id;int regs_offset;int cfgs_offset; +int clut_offset;struct atmel_hlcdc_formats *formats;struct atmel_hlcdc_layer_cfg_layout layout;int max_width;
@@ -414,6 +421,14 @@ static inline u32 atmel_hlcdc_layer_read_cfg(struct atmel_hlcdc_layer *layer, (cfgid * sizeof(u32))); } +static inline void atmel_hlcdc_layer_write_clut (struct atmel_hlcdc_layer *layer, +unsigned int c,u32 val) +{ +atmel_hlcdc_layer_write_reg (layer, + layer->desc->clut_offset + c *sizeof (u32), + val); +} +static inline void atmel_hlcdc_layer_init (struct atmel_hlcdc_layer *layer,const struct atmel_hlcdc_layer_desc *desc,struct regmap *regmap)
@@ -432,6 +447,9 @@ void atmel_hlcdc_plane_irq(struct atmel_hlcdc_plane *plane);int atmel_hlcdc_plane_prepare_disc_area (struct drm_crtc_state *c_state);int atmel_hlcdc_plane_prepare_ahb_routing (struct drm_crtc_state *c_state); +void atmel_hlcdc_gamma_set (struct drm_crtc *c,u16 r,u16 g,u16 b,int idx); +void atmel_hlcdc_gamma_get (struct drm_crtc *c,u16 *r,u16 *g,u16 *b,int idx); +void atmel_hlcdc_crtc_irq (struct drm_crtc *c);int atmel_hlcdc_crtc_create (struct drm_device *dev);
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c +5 -0
@@ -83,6 +83,7 @@ drm_plane_state_to_atmel_hlcdc_plane_state(struct drm_plane_state *s)#define SUBPIXEL_MASK 0xffffstatic uint32_t rgb_formats[] = { +DRM_FORMAT_C8 ,DRM_FORMAT_XRGB4444 ,DRM_FORMAT_ARGB4444 ,DRM_FORMAT_RGBA4444 ,
@@ -100,6 +101,7 @@ struct atmel_hlcdc_formats atmel_hlcdc_plane_rgb_formats = { };static uint32_t rgb_and_yuv_formats[] = { +DRM_FORMAT_C8 ,DRM_FORMAT_XRGB4444 ,DRM_FORMAT_ARGB4444 ,DRM_FORMAT_RGBA4444 ,
@@ -128,6 +130,9 @@ struct atmel_hlcdc_formats atmel_hlcdc_plane_rgb_and_yuv_formats = {static int atmel_hlcdc_format_to_plane_mode (u32 format,u32 *mode) {switch (format) { +case DRM_FORMAT_C8 : + *mode =ATMEL_HLCDC_C8_MODE ; +break ;case DRM_FORMAT_XRGB4444 : *mode =ATMEL_HLCDC_XRGB4444_MODE ;break ;
drivers/gpu/drm/drm_fb_cma_helper.c +35 -17
91 lines not on this page · raw message
include/drm/drm_fb_cma_helper.h +6 -0
@@ -15,6 +15,10 @@ struct drm_mode_fb_cmd2;struct drm_plane ;struct drm_plane_state ; +struct drm_fbdev_cma *drm_fbdev_cma_init_with_funcs2 (struct drm_device *dev, +unsigned int preferred_bpp,unsigned int max_conn_count, +const struct drm_framebuffer_funcs *framebuffer_funcs, +const struct drm_fb_helper_funcs *fb_helper_funcs);struct drm_fbdev_cma *drm_fbdev_cma_init_with_funcs (struct drm_device *dev,unsigned int preferred_bpp,unsigned int max_conn_count,const struct drm_framebuffer_funcs *funcs);
@@ -22,6 +26,8 @@ struct drm_fbdev_cma *drm_fbdev_cma_init(struct drm_device *dev, unsigned int preferred_bpp, unsigned int max_conn_count);void drm_fbdev_cma_fini (struct drm_fbdev_cma *fbdev_cma); +int drm_fbdev_cma_create (struct drm_fb_helper *helper, +struct drm_fb_helper_surface_size *sizes);void drm_fbdev_cma_restore_mode (struct drm_fbdev_cma *fbdev_cma);void drm_fbdev_cma_hotplug_event (struct drm_fbdev_cma *fbdev_cma);void drm_fbdev_cma_set_suspend (struct drm_fbdev_cma *fbdev_cma,int state);
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 18 lines · On Thu, 15 Jun 2017 11:54:29 +0200 Peter Rosin <[email protected]> wrote:
Quoted 17 lines · Boris Brezillon
Hi Peter,
Quoted 12 lines · On Tue, 13 Jun 2017 16:34:25 +0200 Peter Rosin <[email protected]> wrote:
Hi!
I need color lookup support for the atmel-hlcdc driver, and had a peek at the code. I also looked at the
drivers/gpu/drm/stmdriver and came up with the below diff. It compiles, but I have not booted it for the simple reason that I can't imagine it will work.Sure, the code fills the clut registers in the .load_lut helper function and I think it might even do the right thing when setting up the mode. I'm less sure DMA will work correctly? It might, but I haven't looked at it for many seconds...
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
The big question is how the color info gets into the new clut array I created in
atmel_hlcdc_crtc? When I look at the stm driver, which does it just like this AFAICT I just don't see it. So, what I'm I missing?You should look at
drm_atomic_helper_legacy_gamma_set()and its users.Ok, thanks. I had a long look and could not get it to work at all.
Probably because you're trying to set this up through the emulated fbdev interface. The solution I proposed is supposed to be accessed through DRM ioctls.
Quoted 2 lines
So,
I did as below instead. However, there are a few glaring problems...
Well, I doubt this will be accepted. The fbdev emulation layer is supposed to be rather dumb, partly because DRM people want developers to switch to the DRM interface.
Also note that I won't accept a solution that supports setting the LUT table only through the fbdev interface, so please try to make it work the DRM way before you even consider modifying the fbdev emulation layer.
Quoted 8 lines
Something, somewhere, sets up default entries for the 16 first entries of the palette and seem to expect them to stay as some kind of safe basic palette, and my applications don't handle it too well. When they want to draw black, they get a poisonous cyan/green instead etc. But it's pretty close. Can anyone provide some clue as to how that is supposed to be handled?
Quoted 8 lines
Also, I had to change the second argument of the
drm_fbdev_cma_init... call at the end of atmel_hlcdc_dc.c:atmel_hlcdc_dc_load() from 24 to 8 to make it possible to set 8-modes. However, doing so fucks up 24-bit modes. Which made me suspect that no non-24-bit mode work w/o my patch. And I could indeed only get 24-bit modes to work, unless I changed this value to 16. Then RGB565 works like a charm, but RGB888 don't. What's up with that? Seems like a rather silly limitation, but it's perhaps just a bug?
I'm pretty sure this is not a bug. AFAIR, prefered_bpp is used when you don't explicitly specify the video mode you want to use on the cmdline [1].
[1]http://elixir.free-electrons.com/linux/v3.11/source/Documentation/fb/modedb.txt
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 25 lines · Boris Brezillon
Quoted 22 lines · On Thu, 15 Jun 2017 11:54:29 +0200 Peter Rosin <[email protected]> wrote:
Quoted 21 lines · Boris Brezillon
Hi Peter,
Quoted 15 lines · On Tue, 13 Jun 2017 16:34:25 +0200 Peter Rosin <[email protected]> wrote:
Hi!
I need color lookup support for the atmel-hlcdc driver, and had a peek at the code. I also looked at the
drivers/gpu/drm/stmdriver and came up with the below diff. It compiles, but I have not booted it for the simple reason that I can't imagine it will work.Sure, the code fills the clut registers in the .load_lut helper function and I think it might even do the right thing when setting up the mode. I'm less sure DMA will work correctly? It might, but I haven't looked at it for many seconds...
The big question is how the color info gets into the new clut array I created in
atmel_hlcdc_crtc? When I look at the stm driver, which does it just like this AFAICT I just don't see it. So, what I'm I missing?
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
You should look at
drm_atomic_helper_legacy_gamma_set()and its users.Ok, thanks. I had a long look and could not get it to work at all.
Probably because you're trying to set this up through the emulated fbdev interface. The solution I proposed is supposed to be accessed through DRM ioctls.
Yes, that seems like the root cause of most of my troubles. But, the apps I have seem to use the fbdev interface, and if the emulation is poorly done, they won't work right...
Quoted 6 lines
Quoted 2 lines
So,
I did as below instead. However, there are a few glaring problems...Well, I doubt this will be accepted. The fbdev emulation layer is supposed to be rather dumb, partly because DRM people want developers to switch to the DRM interface.
Sigh.
Quoted 4 lines
Also note that I won't accept a solution that supports setting the LUT table only through the fbdev interface, so please try to make it work the DRM way before you even consider modifying the fbdev emulation layer.
Ok, I'll have another look. But to me, it's a maze...
Quoted 17 lines
Quoted 8 lines
Something, somewhere, sets up default entries for the 16 first entries of the palette and seem to expect them to stay as some kind of safe basic palette, and my applications don't handle it too well. When they want to draw black, they get a poisonous cyan/green instead etc. But it's pretty close. Can anyone provide some clue as to how that is supposed to be handled?
Quoted 8 lines
Also, I had to change the second argument of the
drm_fbdev_cma_init... call at the end of atmel_hlcdc_dc.c:atmel_hlcdc_dc_load() from 24 to 8 to make it possible to set 8-modes. However, doing so fucks up 24-bit modes. Which made me suspect that no non-24-bit mode work w/o my patch. And I could indeed only get 24-bit modes to work, unless I changed this value to 16. Then RGB565 works like a charm, but RGB888 don't. What's up with that? Seems like a rather silly limitation, but it's perhaps just a bug?
Quoted 6 lines
I'm pretty sure this is not a bug. AFAIR,
prefered_bppis used when you don't explicitly specify the video mode you want to use on the cmdline [1].[1]http://elixir.free-electrons.com/linux/v3.11/source/Documentation/fb/modedb.txt
(Why refer to v3.11 docs?)
Let's start with some basics, I tried to add
video=atmel-hclcd-dc:1024x768-16
and
video=atmel_hclcd_dc:1024x768-16
to the kernel cmdline of an unpatched linux-next kernel. No dice, I can still only access RBG888. I'm obviously in need of some hand-holding...
How am I supposed to get a 16-bit mode?
Cheers,
peda
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 84 lines · On Thu, 15 Jun 2017 13:47:35 +0200 Peter Rosin <[email protected]> wrote:
Quoted 25 lines · Boris Brezillon
Quoted 22 lines · On Thu, 15 Jun 2017 11:54:29 +0200 Peter Rosin <[email protected]> wrote:
Quoted 21 lines · Boris Brezillon
Hi Peter,
Quoted 15 lines · On Tue, 13 Jun 2017 16:34:25 +0200 Peter Rosin <[email protected]> wrote:
Hi!
I need color lookup support for the atmel-hlcdc driver, and had a peek at the code. I also looked at the
drivers/gpu/drm/stmdriver and came up with the below diff. It compiles, but I have not booted it for the simple reason that I can't imagine it will work.Sure, the code fills the clut registers in the .load_lut helper function and I think it might even do the right thing when setting up the mode. I'm less sure DMA will work correctly? It might, but I haven't looked at it for many seconds...
The big question is how the color info gets into the new clut array I created in
atmel_hlcdc_crtc? When I look at the stm driver, which does it just like this AFAICT I just don't see it. So, what I'm I missing?Quoted 7 lines
Quoted 3 lines
Quoted 1 line
You should look at
drm_atomic_helper_legacy_gamma_set()and its users.Ok, thanks. I had a long look and could not get it to work at all.
Probably because you're trying to set this up through the emulated fbdev interface. The solution I proposed is supposed to be accessed through DRM ioctls.
Yes, that seems like the root cause of most of my troubles. But, the apps I have seem to use the fbdev interface, and if the emulation is poorly done, they won't work right...
Quoted 6 lines
Quoted 2 lines
So,
I did as below instead. However, there are a few glaring problems...Well, I doubt this will be accepted. The fbdev emulation layer is supposed to be rather dumb, partly because DRM people want developers to switch to the DRM interface.
Sigh.
Quoted 4 lines
Also note that I won't accept a solution that supports setting the LUT table only through the fbdev interface, so please try to make it work the DRM way before you even consider modifying the fbdev emulation layer.
Ok, I'll have another look. But to me, it's a maze...
Quoted 17 lines
Quoted 8 lines
Something, somewhere, sets up default entries for the 16 first entries of the palette and seem to expect them to stay as some kind of safe basic palette, and my applications don't handle it too well. When they want to draw black, they get a poisonous cyan/green instead etc. But it's pretty close. Can anyone provide some clue as to how that is supposed to be handled?
Quoted 8 lines
Also, I had to change the second argument of the
drm_fbdev_cma_init... call at the end of atmel_hlcdc_dc.c:atmel_hlcdc_dc_load() from 24 to 8 to make it possible to set 8-modes. However, doing so fucks up 24-bit modes. Which made me suspect that no non-24-bit mode work w/o my patch. And I could indeed only get 24-bit modes to work, unless I changed this value to 16. Then RGB565 works like a charm, but RGB888 don't. What's up with that? Seems like a rather silly limitation, but it's perhaps just a bug?Quoted 6 lines
I'm pretty sure this is not a bug. AFAIR,
prefered_bppis used when you don't explicitly specify the video mode you want to use on the cmdline [1].[1]http://elixir.free-electrons.com/linux/v3.11/source/Documentation/fb/modedb.txt
(Why refer to v3.11 docs?)
Let's start with some basics, I tried to add
video=atmel-hclcd-dc:1024x768-16
Quoted 8 lines
and
video=atmel_hclcd_dc:1024x768-16to the kernel cmdline of an unpatched linux-next kernel. No dice, I can still only access RBG888. I'm obviously in need of some hand-holding...
How am I supposed to get a 16-bit mode?
You should have a look at [1].
[1]https://www.at91.com/linux4sam/bin/view/Linux4SAM/UsingAtmelDRMDriver#Choose_supported_modes
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 91 lines · Boris Brezillon
Quoted 88 lines · On Thu, 15 Jun 2017 13:47:35 +0200 Peter Rosin <[email protected]> wrote:
Quoted 25 lines · Boris Brezillon
Quoted 22 lines · On Thu, 15 Jun 2017 11:54:29 +0200 Peter Rosin <[email protected]> wrote:
Quoted 21 lines · Boris Brezillon
Hi Peter,
Quoted 15 lines · On Tue, 13 Jun 2017 16:34:25 +0200 Peter Rosin <[email protected]> wrote:
Hi!
I need color lookup support for the atmel-hlcdc driver, and had a peek at the code. I also looked at the
drivers/gpu/drm/stmdriver and came up with the below diff. It compiles, but I have not booted it for the simple reason that I can't imagine it will work.Sure, the code fills the clut registers in the .load_lut helper function and I think it might even do the right thing when setting up the mode. I'm less sure DMA will work correctly? It might, but I haven't looked at it for many seconds...
The big question is how the color info gets into the new clut array I created in
atmel_hlcdc_crtc? When I look at the stm driver, which does it just like this AFAICT I just don't see it. So, what I'm I missing?Quoted 7 lines
Quoted 3 lines
Quoted 1 line
You should look at
drm_atomic_helper_legacy_gamma_set()and its users.Ok, thanks. I had a long look and could not get it to work at all.
Probably because you're trying to set this up through the emulated fbdev interface. The solution I proposed is supposed to be accessed through DRM ioctls.
Yes, that seems like the root cause of most of my troubles. But, the apps I have seem to use the fbdev interface, and if the emulation is poorly done, they won't work right...
Quoted 6 lines
Quoted 2 lines
So,
I did as below instead. However, there are a few glaring problems...Well, I doubt this will be accepted. The fbdev emulation layer is supposed to be rather dumb, partly because DRM people want developers to switch to the DRM interface.
Sigh.
Quoted 4 lines
Also note that I won't accept a solution that supports setting the LUT table only through the fbdev interface, so please try to make it work the DRM way before you even consider modifying the fbdev emulation layer.
Ok, I'll have another look. But to me, it's a maze...
Quoted 17 lines
Quoted 8 lines
Something, somewhere, sets up default entries for the 16 first entries of the palette and seem to expect them to stay as some kind of safe basic palette, and my applications don't handle it too well. When they want to draw black, they get a poisonous cyan/green instead etc. But it's pretty close. Can anyone provide some clue as to how that is supposed to be handled?
Quoted 8 lines
Also, I had to change the second argument of the
drm_fbdev_cma_init... call at the end of atmel_hlcdc_dc.c:atmel_hlcdc_dc_load() from 24 to 8 to make it possible to set 8-modes. However, doing so fucks up 24-bit modes. Which made me suspect that no non-24-bit mode work w/o my patch. And I could indeed only get 24-bit modes to work, unless I changed this value to 16. Then RGB565 works like a charm, but RGB888 don't. What's up with that? Seems like a rather silly limitation, but it's perhaps just a bug?Quoted 6 lines
I'm pretty sure this is not a bug. AFAIR,
prefered_bppis used when you don't explicitly specify the video mode you want to use on the cmdline [1].[1]http://elixir.free-electrons.com/linux/v3.11/source/Documentation/fb/modedb.txt
(Why refer to v3.11 docs?)
Let's start with some basics, I tried to add
video=atmel-hclcd-dc:1024x768-16and
video=atmel_hclcd_dc:1024x768-16
Quoted 9 lines
Quoted 4 lines
to the kernel cmdline of an unpatched linux-next kernel. No dice, I can still only access RBG888. I'm obviously in need of some hand-holding...
How am I supposed to get a 16-bit mode?
You should have a look at [1].
[1]https://www.at91.com/linux4sam/bin/view/Linux4SAM/UsingAtmelDRMDriver#Choose_supported_modes
Ahh, it works with video=Unknown-1:1024x768-16
Thanks!
So, is this below better? I'll follow-up with a patch I need for the fbdev emulation to work.
I can't easily test this newfangled drm stuff, my userspace is oldish, so I don't know if atmel_hlcdc_crtc_atomic_flush() is the correct place to call atmel_hlcdc_crtc_flush_lut and have the palette loaded?
What I'm saying is that I have only tested the fbdev emulation, and I still have trouble with the palette colors (poisonous green/cyan instead of black etc). But that may only be an issue with fbdev?
Cheers,
peda
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c +48 -0
@@ -61,6 +61,7 @@ struct atmel_hlcdc_crtc {struct atmel_hlcdc_dc *dc;struct drm_pending_vblank_event *event;int id; +u32 clut[256 ]; }; static inline struct atmel_hlcdc_crtc *
@@ -140,6 +141,46 @@ static void atmel_hlcdc_crtc_mode_set_nofb(struct drm_crtc *c) cfg); } +static void +atmel_hlcdc_crtc_load_lut (struct drm_crtc *c) +{ +struct atmel_hlcdc_crtc *crtc =drm_crtc_to_atmel_hlcdc_crtc (c); +struct atmel_hlcdc_dc *dc = crtc->dc; +int layer; +int idx; + +for (layer =0 ; layer <ATMEL_HLCDC_MAX_LAYERS ; layer++) { +if (!dc->layers[layer]) +continue ; +for (idx =0 ; idx <256 ; idx++) +atmel_hlcdc_layer_write_clut (dc->layers[layer], + idx, crtc->clut[idx]); + } +} + +static void +atmel_hlcdc_crtc_flush_lut (struct drm_crtc *c) +{ +struct atmel_hlcdc_crtc *crtc =drm_crtc_to_atmel_hlcdc_crtc (c); +struct drm_crtc_state *state = c->state; +struct drm_color_lut *lut; +int idx; + +if (!state->gamma_lut) +return ; + + lut = (struct drm_color_lut *)state->gamma_lut->data; + +for (idx =0 ; idx <256 ; idx++) { + crtc->clut[idx] = + ((lut[idx].red <<8 ) &0xff0000 ) | + (lut[idx].green &0xff00 ) | + (lut[idx].blue >>8 ); + } + +atmel_hlcdc_crtc_load_lut (c); +} +static enum drm_mode_status atmel_hlcdc_crtc_mode_valid (struct drm_crtc *c,const struct drm_display_mode *mode)
@@ -312,6 +353,9 @@ static void atmel_hlcdc_crtc_atomic_flush(struct drm_crtc *crtc, struct drm_crtc_state *old_s) {/* TODO: write common plane control register if available */ + +if (crtc->state->color_mgmt_changed) +atmel_hlcdc_crtc_flush_lut (crtc); }static const struct drm_crtc_helper_funcs lcdc_crtc_helper_funcs = {
@@ -429,6 +473,7 @@ static const struct drm_crtc_funcs atmel_hlcdc_crtc_funcs = { .atomic_destroy_state = atmel_hlcdc_crtc_destroy_state, .enable_vblank = atmel_hlcdc_crtc_enable_vblank, .disable_vblank = atmel_hlcdc_crtc_disable_vblank, + .set_property = drm_atomic_helper_crtc_set_property, };int atmel_hlcdc_crtc_create (struct drm_device *dev)
@@ -484,6 +529,9 @@ int atmel_hlcdc_crtc_create(struct drm_device *dev)drm_crtc_helper_add (&crtc->base, &lcdc_crtc_helper_funcs);drm_crtc_vblank_reset (&crtc->base); +drm_mode_crtc_set_gamma_size (&crtc->base,256 ); +drm_crtc_enable_color_mgmt (&crtc->base,0 , false,256 ); + dc->crtc = &crtc->base;return 0 ;
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c +13 -0
@@ -42,6 +42,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_at91sam9n12_layers[] = { .default_color = 3, .general_config = 4, }, + .clut_offset = 0x400, }, };
@@ -73,6 +74,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_at91sam9x5_layers[] = { .disc_pos = 5, .disc_size = 6, }, + .clut_offset = 0x400, }, { .name = "overlay1",
@@ -91,6 +93,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_at91sam9x5_layers[] = { .chroma_key_mask = 8, .general_config = 9, }, + .clut_offset = 0x800, }, { .name = "high-end-overlay",
@@ -112,6 +115,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_at91sam9x5_layers[] = { .scaler_config = 13, .csc = 14, }, + .clut_offset = 0x1000, }, { .name = "cursor",
@@ -131,6 +135,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_at91sam9x5_layers[] = { .chroma_key_mask = 8, .general_config = 9, }, + .clut_offset = 0x1400, }, };
@@ -162,6 +167,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_sama5d3_layers[] = { .disc_pos = 5, .disc_size = 6, }, + .clut_offset = 0x600, }, { .name = "overlay1",
@@ -180,6 +186,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_sama5d3_layers[] = { .chroma_key_mask = 8, .general_config = 9, }, + .clut_offset = 0xa00, }, { .name = "overlay2",
@@ -198,6 +205,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_sama5d3_layers[] = { .chroma_key_mask = 8, .general_config = 9, }, + .clut_offset = 0xe00, }, { .name = "high-end-overlay",
@@ -223,6 +231,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_sama5d3_layers[] = { }, .csc = 14, }, + .clut_offset = 0x1200, }, { .name = "cursor",
@@ -244,6 +253,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_sama5d3_layers[] = { .general_config = 9, .scaler_config = 13, }, + .clut_offset = 0x1600, }, };
@@ -275,6 +285,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_sama5d4_layers[] = { .disc_pos = 5, .disc_size = 6, }, + .clut_offset = 0x600, }, { .name = "overlay1",
@@ -293,6 +304,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_sama5d4_layers[] = { .chroma_key_mask = 8, .general_config = 9, }, + .clut_offset = 0xa00, }, { .name = "overlay2",
@@ -336,6 +348,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_sama5d4_layers[] = { }, .csc = 14, }, + .clut_offset = 0x1200, }, };
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h +14 -0
@@ -88,6 +88,11 @@#define ATMEL_HLCDC_YUV422SWP BIT(17)#define ATMEL_HLCDC_DSCALEOPT BIT(20) +#define ATMEL_HLCDC_C1_MODE ATMEL_HLCDC_CLUT_MODE(0) +#define ATMEL_HLCDC_C2_MODE ATMEL_HLCDC_CLUT_MODE(1) +#define ATMEL_HLCDC_C4_MODE ATMEL_HLCDC_CLUT_MODE(2) +#define ATMEL_HLCDC_C8_MODE ATMEL_HLCDC_CLUT_MODE(3) +#define ATMEL_HLCDC_XRGB4444_MODE ATMEL_HLCDC_RGB_MODE(0)#define ATMEL_HLCDC_ARGB4444_MODE ATMEL_HLCDC_RGB_MODE(1)#define ATMEL_HLCDC_RGBA4444_MODE ATMEL_HLCDC_RGB_MODE(2)
@@ -259,6 +264,7 @@ struct atmel_hlcdc_layer_desc {int id;int regs_offset;int cfgs_offset; +int clut_offset;struct atmel_hlcdc_formats *formats;struct atmel_hlcdc_layer_cfg_layout layout;int max_width;
@@ -414,6 +420,14 @@ static inline u32 atmel_hlcdc_layer_read_cfg(struct atmel_hlcdc_layer *layer, (cfgid * sizeof(u32))); } +static inline void atmel_hlcdc_layer_write_clut (struct atmel_hlcdc_layer *layer, +unsigned int c,u32 val) +{ +atmel_hlcdc_layer_write_reg (layer, + layer->desc->clut_offset + c *sizeof (u32), + val); +} +static inline void atmel_hlcdc_layer_init (struct atmel_hlcdc_layer *layer,const struct atmel_hlcdc_layer_desc *desc,struct regmap *regmap)
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c +5 -0
@@ -83,6 +83,7 @@ drm_plane_state_to_atmel_hlcdc_plane_state(struct drm_plane_state *s)#define SUBPIXEL_MASK 0xffffstatic uint32_t rgb_formats[] = { +DRM_FORMAT_C8 ,DRM_FORMAT_XRGB4444 ,DRM_FORMAT_ARGB4444 ,DRM_FORMAT_RGBA4444 ,
@@ -100,6 +101,7 @@ struct atmel_hlcdc_formats atmel_hlcdc_plane_rgb_formats = { };static uint32_t rgb_and_yuv_formats[] = { +DRM_FORMAT_C8 ,DRM_FORMAT_XRGB4444 ,DRM_FORMAT_ARGB4444 ,DRM_FORMAT_RGBA4444 ,
@@ -128,6 +130,9 @@ struct atmel_hlcdc_formats atmel_hlcdc_plane_rgb_and_yuv_formats = {static int atmel_hlcdc_format_to_plane_mode (u32 format,u32 *mode) {switch (format) { +case DRM_FORMAT_C8 : + *mode =ATMEL_HLCDC_C8_MODE ; +break ;case DRM_FORMAT_XRGB4444 : *mode =ATMEL_HLCDC_XRGB4444_MODE ;break ;
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 2 lines · Peter Rosin
So, is this below better? I'll follow-up with a patch I need for the fbdev emulation to work.
Without adding gamma callbacks in drm_fb_helper_funcs I hit
/* * The driver really shouldn't advertise pseudo/directcolor * visuals if it can't deal with the palette. */ if (WARN_ON(!fb_helper->funcs->gamma_set || !fb_helper->funcs->gamma_get)) return -EINVAL;
in drm_fb_helper.c:setcolreg(), so I need this patch which basically exposes some guts from fbdev_cma and glues it with the new clut handling in the atmel_hlcdc driver.
Cheers,
peda
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c +49 -0
@@ -158,6 +158,54 @@ atmel_hlcdc_crtc_load_lut(struct drm_crtc *c) } } +void atmel_hlcdc_gamma_set (struct drm_crtc *c, +u16 r,u16 g,u16 b,int idx) +{ +struct atmel_hlcdc_crtc *crtc =drm_crtc_to_atmel_hlcdc_crtc (c); +struct drm_crtc_state *state = c->state; +struct drm_color_lut *lut; + +if (idx <0 || idx >255 ) +return ; + +if (state->gamma_lut) { + lut = (struct drm_color_lut *)state->gamma_lut->data; + + lut[idx].red = r; + lut[idx].green = g; + lut[idx].blue = b; + } + + crtc->clut[idx] = ((r <<8 ) &0xff0000 ) | (g &0xff00 ) | (b >>8 ); +} + +void atmel_hlcdc_gamma_get (struct drm_crtc *c, +u16 *r,u16 *g,u16 *b,int idx) +{ +struct atmel_hlcdc_crtc *crtc =drm_crtc_to_atmel_hlcdc_crtc (c); +struct drm_crtc_state *state = c->state; +struct drm_color_lut *lut; + +if (idx <0 || idx >255 ) +return ; + +if (state->gamma_lut) { + lut = (struct drm_color_lut *)state->gamma_lut->data; + + *r = lut[idx].red; + *g = lut[idx].green; + *b = lut[idx].blue; +return ; + } + + *r = (crtc->clut[idx] >>8 ) &0xff00 ; + *g = crtc->clut[idx] &0xff00 ; + *b = (crtc->clut[idx] <<8 ) &0xff00 ; + *r |= *r >>8 ; + *g |= *g >>8 ; + *b |= *b >>8 ; +} +static void atmel_hlcdc_crtc_flush_lut (struct drm_crtc *c) {
@@ -363,6 +411,7 @@ static const struct drm_crtc_helper_funcs lcdc_crtc_helper_funcs = { .mode_set = drm_helper_crtc_mode_set, .mode_set_nofb = atmel_hlcdc_crtc_mode_set_nofb, .mode_set_base = drm_helper_crtc_mode_set_base, + .load_lut = atmel_hlcdc_crtc_load_lut, .disable = atmel_hlcdc_crtc_disable, .enable = atmel_hlcdc_crtc_enable, .atomic_check = atmel_hlcdc_crtc_atomic_check,
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c +10 -2
@@ -601,6 +601,12 @@ static int atmel_hlcdc_dc_modeset_init(struct drm_device *dev)return 0 ; } +static const struct drm_fb_helper_funcs atmel_hlcdc_fb_cma_helper_funcs = { + .gamma_set = atmel_hlcdc_gamma_set, + .gamma_get = atmel_hlcdc_gamma_get, + .fb_probe = drm_fbdev_cma_create, +}; +static int atmel_hlcdc_dc_load (struct drm_device *dev) {struct platform_device *pdev =to_platform_device (dev->dev);
@@ -664,8 +670,10 @@ static int atmel_hlcdc_dc_load(struct drm_device *dev)platform_set_drvdata (pdev, dev); - dc->fbdev =drm_fbdev_cma_init (dev,24 , - dev->mode_config.num_connector); + dc->fbdev =drm_fbdev_cma_init_with_funcs2 (dev,24 , + dev->mode_config.num_connector, +NULL , + &atmel_hlcdc_fb_cma_helper_funcs);if (IS_ERR (dc->fbdev)) dc->fbdev =NULL ;
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h +4 -0
@@ -32,6 +32,7 @@#include <drm/drm_atomic_helper.h> #include <drm/drm_crtc.h> #include <drm/drm_crtc_helper.h> +#include <drm/drm_fb_helper.h> #include <drm/drm_fb_cma_helper.h> #include <drm/drm_gem_cma_helper.h> #include <drm/drm_panel.h>
@@ -446,6 +447,9 @@ void atmel_hlcdc_plane_irq(struct atmel_hlcdc_plane *plane);int atmel_hlcdc_plane_prepare_disc_area (struct drm_crtc_state *c_state);int atmel_hlcdc_plane_prepare_ahb_routing (struct drm_crtc_state *c_state); +void atmel_hlcdc_gamma_set (struct drm_crtc *c,u16 r,u16 g,u16 b,int idx); +void atmel_hlcdc_gamma_get (struct drm_crtc *c,u16 *r,u16 *g,u16 *b,int idx); +void atmel_hlcdc_crtc_irq (struct drm_crtc *c);int atmel_hlcdc_crtc_create (struct drm_device *dev);
drivers/gpu/drm/drm_fb_cma_helper.c +45 -10
101 lines not on this page · raw message
include/drm/drm_fb_cma_helper.h +7 -1
@@ -15,13 +15,19 @@ struct drm_mode_fb_cmd2;struct drm_plane ;struct drm_plane_state ; +struct drm_fbdev_cma *drm_fbdev_cma_init_with_funcs2 (struct drm_device *dev, +unsigned int preferred_bpp,unsigned int max_conn_count, +const struct drm_framebuffer_funcs *framebuffer_funcs, +const struct drm_fb_helper_funcs *fb_helper_funcs);struct drm_fbdev_cma *drm_fbdev_cma_init_with_funcs (struct drm_device *dev,unsigned int preferred_bpp,unsigned int max_conn_count, -const struct drm_framebuffer_funcs *funcs); +const struct drm_framebuffer_funcs *framebuffer_funcs);struct drm_fbdev_cma *drm_fbdev_cma_init (struct drm_device *dev,unsigned int preferred_bpp,unsigned int max_conn_count);void drm_fbdev_cma_fini (struct drm_fbdev_cma *fbdev_cma); +int drm_fbdev_cma_create (struct drm_fb_helper *helper, +struct drm_fb_helper_surface_size *sizes);void drm_fbdev_cma_restore_mode (struct drm_fbdev_cma *fbdev_cma);void drm_fbdev_cma_hotplug_event (struct drm_fbdev_cma *fbdev_cma);void drm_fbdev_cma_set_suspend (struct drm_fbdev_cma *fbdev_cma,int state);
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 27 lines · Peter Rosin
Quoted 2 lines · Peter Rosin
So, is this below better? I'll follow-up with a patch I need for the fbdev emulation to work.
Without adding gamma callbacks in
drm_fb_helper_funcsI hit/* * The driver really shouldn't advertise pseudo/directcolor * visuals if it can't deal with the palette. */ if (WARN_ON(!fb_helper->funcs->gamma_set || !fb_helper->funcs->gamma_get)) return -EINVAL;in drm_fb_helper.c:setcolreg(), so I need this patch which basically exposes some guts from
fbdev_cmaand glues it with the new clut handling in theatmel_hlcdcdriver.Cheers,
pedadrivers/gpu/drm/drm_fb_cma_helper.c +7
-0+ +/** +* drm_fbdev_cma_init_with_funcs() - Allocate and initializes a drm_fbdev_cma struct +* @dev: DRM device +* @preferred_bpp: Preferred bits per pixel for the device +* @max_conn_count: Maximum number of connectors +* @framebuffer_funcs: framebuffer functions, in particular a custom dirty() callback
drivers/gpu/drm/drm_fb_cma_helper.c struct drm_fbdev_cma *drm_fbdev_cma_init_with_funcs(struct drm_device *dev, · line 604
Quoted 10 lines
drivers/gpu/drm/drm_fb_cma_helper.c +10
-0+* +* Returns a newly allocated drm_fbdev_cma struct or a ERR_PTR. +*/ +struct drm_fbdev_cma *drm_fbdev_cma_init_with_funcs (struct drm_device *dev, +unsigned int preferred_bpp,unsigned int max_conn_count, +const struct drm_framebuffer_funcs *framebuffer_funcs) +{ +return drm_fbdev_cma_init_with_funcs2 (dev, preferred_bpp, + max_conn_count, + funcs,NULL );
s/funcs/framebuffer_funcs/
Sorry about that. I'm planning to resend this as a series anyway with proper commit messages and signoffs etc.
Cheers,
peda
Quoted 2 lines
+}
EXPORT_SYMBOL_GPL(drm_fbdev_cma_init_with_funcs);
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 25 lines · Boris Brezillon
Quoted 22 lines · On Thu, 15 Jun 2017 11:54:29 +0200 Peter Rosin <[email protected]> wrote:
Quoted 21 lines · Boris Brezillon
Hi Peter,
Quoted 15 lines · On Tue, 13 Jun 2017 16:34:25 +0200 Peter Rosin <[email protected]> wrote:
Hi!
I need color lookup support for the atmel-hlcdc driver, and had a peek at the code. I also looked at the
drivers/gpu/drm/stmdriver and came up with the below diff. It compiles, but I have not booted it for the simple reason that I can't imagine it will work.Sure, the code fills the clut registers in the .load_lut helper function and I think it might even do the right thing when setting up the mode. I'm less sure DMA will work correctly? It might, but I haven't looked at it for many seconds...
The big question is how the color info gets into the new clut array I created in
atmel_hlcdc_crtc? When I look at the stm driver, which does it just like this AFAICT I just don't see it. So, what I'm I missing?
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
You should look at
drm_atomic_helper_legacy_gamma_set()and its users.Ok, thanks. I had a long look and could not get it to work at all.
Probably because you're trying to set this up through the emulated fbdev interface. The solution I proposed is supposed to be accessed through DRM ioctls.
Yup, no one typed the fbdev emulation support to use the new&fancy color manager stuff if available. That needs to be done if you want that. Also note that even the existing legacy lut support for fbdev is in imo rather bad shape, and I really don't want to see it's usage spread (it has its own special functions which use neither the old nor new kms interfaces, forcing drivers to duplicate stuff for no gain at all).
Quoted 11 lines
Quoted 2 lines
So,
I did as below instead. However, there are a few glaring problems...Well, I doubt this will be accepted. The fbdev emulation layer is supposed to be rather dumb, partly because DRM people want developers to switch to the DRM interface.
Also note that I won't accept a solution that supports setting the LUT table only through the fbdev interface, so please try to make it work the DRM way before you even consider modifying the fbdev emulation layer.
Correct :-)
Bunch more details: fbdev emulation in drm_fb_helper.c uses ->gamma_set and ->load_lut, that needs to be replaced by the proper kms interfaces (and using the color manager properties for atomic drivers directly, if available).
Cheers, Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel