From: Peter Rosin <peda@axentia.se>
To: linux-kernel@vger.kernel.org
Cc: Peter Rosin <peda@axentia.se>,
Boris Brezillon <boris.brezillon@free-electrons.com>,
David Airlie <airlied@linux.ie>,
Daniel Vetter <daniel.vetter@intel.com>,
Jani Nikula <jani.nikula@linux.intel.com>,
Sean Paul <seanpaul@chromium.org>,
dri-devel@lists.freedesktop.org
Subject: [RFC PATCH 3/3] atmel-hlcdc: add clut support for legacy fbdev
Date: Fri, 16 Jun 2017 11:12:27 +0200 [thread overview]
Message-ID: <1497604347-17960-4-git-send-email-peda@axentia.se> (raw)
In-Reply-To: <1497604347-17960-1-git-send-email-peda@axentia.se>
The clut is also synchronized with the drm gamma_lut state.
Signed-off-by: Peter Rosin <peda@axentia.se>
---
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 49 ++++++++++++++++++++++++++
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 12 +++++--
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h | 4 +++
3 files changed, 63 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
index 75871b5..54ecf56 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
@@ -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,
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
index 4f6ef07..9a09c73 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
@@ -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;
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h
index 709f7b9..1b13224 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h
@@ -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>
@@ -448,6 +449,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);
--
2.1.4
prev parent reply other threads:[~2017-06-16 9:12 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-16 9:12 [RFC PATCH 0/3] drm: atmel-hlcdc: clut support Peter Rosin
2017-06-16 9:12 ` [RFC PATCH 1/3] atmel-hlcdc: add support for 8-bit color lookup table mode Peter Rosin
2017-06-16 10:01 ` Boris Brezillon
2017-06-16 15:54 ` Peter Rosin
2017-06-16 16:15 ` Boris Brezillon
2017-06-16 21:12 ` Peter Rosin
2017-06-16 22:25 ` Peter Rosin
2017-06-16 22:46 ` Peter Rosin
2017-06-17 5:36 ` Boris Brezillon
2017-06-17 17:51 ` Peter Rosin
2017-06-16 9:12 ` [RFC PATCH 2/3] drm/fb-cma-helper: expose more of fb cma guts Peter Rosin
2017-06-16 9:12 ` Peter Rosin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1497604347-17960-4-git-send-email-peda@axentia.se \
--to=peda@axentia.se \
--cc=airlied@linux.ie \
--cc=boris.brezillon@free-electrons.com \
--cc=daniel.vetter@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=seanpaul@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®