public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: agheorghe <Alexandru_Gheorghe@mentor.com>
To: <Alexandru_Gheorghe@mentor.com>,
	<laurent.pinchart@ideasonboard.com>,
	<linux-renesas-soc@vger.kernel.org>,
	<dri-devel@lists.freedesktop.org>, <linux-media@vger.kernel.org>
Subject: [PATCH 1/2] v4l: vsp1: Add support for colorkey alpha blending
Date: Thu, 4 May 2017 13:53:32 +0300	[thread overview]
Message-ID: <1493895213-12573-2-git-send-email-Alexandru_Gheorghe@mentor.com> (raw)
In-Reply-To: <1493895213-12573-1-git-send-email-Alexandru_Gheorghe@mentor.com>

The vsp2 hw supports changing of the alpha of pixels that match a color
key, this patch adds support for this feature in order to be used by
the rcar-du driver.
The colorkey is interpreted different depending of the pixel format:
	* RGB   - all color components have to match.
	* YCbCr - only the Y component has to match.

Signed-off-by: agheorghe <Alexandru_Gheorghe@mentor.com>
---
 drivers/media/platform/vsp1/vsp1_drm.c  |  3 +++
 drivers/media/platform/vsp1/vsp1_rpf.c  | 10 ++++++++--
 drivers/media/platform/vsp1/vsp1_rwpf.h |  3 +++
 include/media/vsp1.h                    |  3 +++
 4 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/vsp1/vsp1_drm.c b/drivers/media/platform/vsp1/vsp1_drm.c
index 3627f08..a4d0aee 100644
--- a/drivers/media/platform/vsp1/vsp1_drm.c
+++ b/drivers/media/platform/vsp1/vsp1_drm.c
@@ -393,6 +393,9 @@ int vsp1_du_atomic_update(struct device *dev, unsigned int rpf_index,
 	else
 		rpf->format.plane_fmt[1].bytesperline = cfg->pitch;
 	rpf->alpha = cfg->alpha;
+	rpf->colorkey = cfg->colorkey;
+	rpf->colorkey_en = cfg->colorkey_en;
+	rpf->colorkey_alpha = cfg->colorkey_alpha;
 	rpf->interlaced = cfg->interlaced;
 
 	if (soc_device_match(r8a7795es1) && rpf->interlaced) {
diff --git a/drivers/media/platform/vsp1/vsp1_rpf.c b/drivers/media/platform/vsp1/vsp1_rpf.c
index a12d6f9..91f2a9f 100644
--- a/drivers/media/platform/vsp1/vsp1_rpf.c
+++ b/drivers/media/platform/vsp1/vsp1_rpf.c
@@ -356,8 +356,14 @@ static void rpf_configure(struct vsp1_entity *entity,
 	}
 
 	vsp1_rpf_write(rpf, dl, VI6_RPF_MSK_CTRL, 0);
-	vsp1_rpf_write(rpf, dl, VI6_RPF_CKEY_CTRL, 0);
-
+	if (rpf->colorkey_en) {
+		vsp1_rpf_write(rpf, dl, VI6_RPF_CKEY_SET0,
+			       (rpf->colorkey_alpha << 24) | rpf->colorkey);
+		vsp1_rpf_write(rpf, dl, VI6_RPF_CKEY_CTRL,
+			       VI6_RPF_CKEY_CTRL_SAPE0);
+	} else {
+		vsp1_rpf_write(rpf, dl, VI6_RPF_CKEY_CTRL, 0);
+	}
 }
 
 static const struct vsp1_entity_operations rpf_entity_ops = {
diff --git a/drivers/media/platform/vsp1/vsp1_rwpf.h b/drivers/media/platform/vsp1/vsp1_rwpf.h
index fbe6aa6..2d7f4b9 100644
--- a/drivers/media/platform/vsp1/vsp1_rwpf.h
+++ b/drivers/media/platform/vsp1/vsp1_rwpf.h
@@ -51,6 +51,9 @@ struct vsp1_rwpf {
 	unsigned int brs_input;
 
 	unsigned int alpha;
+	u32 colorkey;
+	bool colorkey_en;
+	u32 colorkey_alpha;
 
 	u32 mult_alpha;
 	u32 outfmt;
diff --git a/include/media/vsp1.h b/include/media/vsp1.h
index 97265f7..879f464 100644
--- a/include/media/vsp1.h
+++ b/include/media/vsp1.h
@@ -32,6 +32,9 @@ struct vsp1_du_atomic_config {
 	struct v4l2_rect dst;
 	unsigned int alpha;
 	unsigned int zpos;
+	u32 colorkey;
+	bool colorkey_en;
+	u32 colorkey_alpha;
 	bool interlaced;
 };
 
-- 
1.9.1

  reply	other threads:[~2017-05-04 10:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-04 10:53 [PATCH 0/2] rcar-du, vsp1: rcar-gen3: Add support for colorkey alpha blending agheorghe
2017-05-04 10:53 ` agheorghe [this message]
2017-05-04 11:21   ` [PATCH 1/2] v4l: vsp1: " Sergei Shtylyov
2017-05-04 11:22   ` Geert Uytterhoeven
2017-05-04 10:53 ` [PATCH 2/2] drm: rcar-du: " agheorghe
2017-05-04 12:44   ` Laurent Pinchart
2017-05-07 10:07     ` Gheorghe, Alexandru

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=1493895213-12573-2-git-send-email-Alexandru_Gheorghe@mentor.com \
    --to=alexandru_gheorghe@mentor.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.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