Skip to contentSkip to conversation

OMAP3630: DSS2: Enable Pre-Multiplied Alpha Support

PATCH Superseded Samreen 3 participants 7 messages Oct 27, 2010 – Nov 4, 2010

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Samreen

author
#0 lore raw

PATCH 1/1 OMAP3630: DSS2: Enable Pre-Multiplied Alpha Support

From: Rajkumar N <[email protected]>

Enable dss to process color formats with pre-mulitplied alpha. With this we can have alpha values defined for each pixel and hence can have different blending values for each pixel. sysfs entry has been created for this and pre-multiplied alpha support is turned off by default.

Also, the check for '(plane != OMAP_DSS_VIDEO1)' in _dispc_setup_plane has been replaced by the correct dss_has_feature check

---
 arch/arm/plat-omap/include/plat/display.h |    1 +
 drivers/video/omap2/dss/dispc.c           |   25 +++++++++++++++++---
 drivers/video/omap2/dss/dss.h             |    3 +-
 drivers/video/omap2/dss/dss_features.c    |   20 ++++++++++++++--
 drivers/video/omap2/dss/dss_features.h    |    1 +
 drivers/video/omap2/dss/manager.c         |    5 +++-
 drivers/video/omap2/dss/overlay.c         |   35 +++++++++++++++++++++++++++++
 7 files changed, 81 insertions(+), 9 deletions(-)
arch/arm/plat-omap/include/plat/display.h +1 -0
index c915a66..d433baf 100644
@@ -268,6 +268,7 @@ struct omap_overlay_info {
 	u16 out_width;	/* if 0, out_width == width */
 	u16 out_height;	/* if 0, out_height == height */
 	u8 global_alpha;
+	u8 pre_mult_alpha;
 };
 
 struct omap_overlay {
drivers/video/omap2/dss/dispc.c +21 -4
index fa40fa5..f1d1797 100644
@@ -773,6 +773,17 @@ static void _dispc_set_vid_size(enum omap_plane plane, int width, int height)
 	dispc_write_reg(vsi_reg[plane-1], val);
 }
 
+static void _dispc_set_pre_mult_alpha(enum omap_plane plane, bool enable)
+{
+	if (!dss_has_feature(FEAT_PREMUL_ALPHA))
+		return;
+
+	BUG_ON(!dss_has_feature(FEAT_GLOBAL_ALPHA_VID1) &&
+		plane == OMAP_DSS_VIDEO1);
+
+	REG_FLD_MOD(dispc_reg_att[plane], enable ? 1 : 0, 28, 28);
+}
+
 static void _dispc_setup_global_alpha(enum omap_plane plane, u8 global_alpha)
 {
 	if (!dss_has_feature(FEAT_GLOBAL_ALPHA))
@@ -1507,7 +1518,8 @@ static int _dispc_setup_plane(enum omap_plane plane,
 		bool ilace,
 		enum omap_dss_rotation_type rotation_type,
 		u8 rotation, int mirror,
-		u8 global_alpha)
+		u8 global_alpha,
+		u8 pre_mult_alpha)
 {
 	const int maxdownscale = cpu_is_omap34xx() ? 4 : 2;
 	bool five_taps = 0;
@@ -1693,8 +1705,11 @@ static int _dispc_setup_plane(enum omap_plane plane,
 
 	_dispc_set_rotation_attrs(plane, rotation, mirror, color_mode);
 
-	if (plane != OMAP_DSS_VIDEO1)
+	if ((plane != OMAP_DSS_VIDEO1) ||
+		dss_has_feature(FEAT_GLOBAL_ALPHA_VID1)) {
+		_dispc_set_pre_mult_alpha(plane, pre_mult_alpha);
 		_dispc_setup_global_alpha(plane, global_alpha);
+	}
 
 	return 0;
 }
@@ -3139,7 +3154,8 @@ int dispc_setup_plane(enum omap_plane plane,
 		       enum omap_color_mode color_mode,
 		       bool ilace,
 		       enum omap_dss_rotation_type rotation_type,
-		       u8 rotation, bool mirror, u8 global_alpha)
+		       u8 rotation, bool mirror, u8 global_alpha,
+		       u8 pre_mult_alpha)
 {
 	int r = 0;
 
@@ -3161,7 +3177,8 @@ int dispc_setup_plane(enum omap_plane plane,
 			   color_mode, ilace,
 			   rotation_type,
 			   rotation, mirror,
-			   global_alpha);
+			   global_alpha,
+			   pre_mult_alpha);
 
 	enable_clocks(0);
 
drivers/video/omap2/dss/dss.h +2 -1
index 5c7940d..2bb515c 100644
@@ -359,7 +359,8 @@ int dispc_setup_plane(enum omap_plane plane,
 		      bool ilace,
 		      enum omap_dss_rotation_type rotation_type,
 		      u8 rotation, bool mirror,
-		      u8 global_alpha);
+		      u8 global_alpha,
+		      u8 pre_mult_alpha);
 
 bool dispc_go_busy(enum omap_channel channel);
 void dispc_go(enum omap_channel channel);
drivers/video/omap2/dss/dss_features.c +17 -3
index 867f68d..1abb8c5 100644
@@ -134,7 +134,7 @@ static struct omap_dss_features omap2_dss_features = {
 };
 
 /* OMAP3 DSS Features */
-static struct omap_dss_features omap3_dss_features = {
+static struct omap_dss_features omap3430_dss_features = {
 	.reg_fields = omap3_dss_reg_fields,
 	.num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields),
 
@@ -146,6 +146,18 @@ static struct omap_dss_features omap3_dss_features = {
 	.supported_color_modes = omap3_dss_supported_color_modes,
 };
 
+static struct omap_dss_features omap3630_dss_features = {
+	.reg_fields = omap3_dss_reg_fields,
+	.num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields),
+
+	.has_feature    = FEAT_GLOBAL_ALPHA | FEAT_PREMUL_ALPHA,
+
+	.num_mgrs = 2,
+	.num_ovls = 3,
+	.supported_displays = omap3_dss_supported_displays,
+	.supported_color_modes = omap3_dss_supported_color_modes,
+};
+
 /* Functions returning values related to a DSS feature */
 int dss_feat_get_num_mgrs(void)
 {
@@ -186,6 +198,8 @@ void dss_features_init(void)
 {
 	if (cpu_is_omap24xx())
 		omap_current_dss_features = &omap2_dss_features;
-	else
-		omap_current_dss_features = &omap3_dss_features;
+	else if (cpu_is_omap3630())
+		omap_current_dss_features = &omap3630_dss_features;
+	else if (cpu_is_omap34xx())
+		omap_current_dss_features = &omap3430_dss_features;
 }
drivers/video/omap2/dss/dss_features.h +1 -0
index cb231ea..f287da8 100644
@@ -27,6 +27,7 @@
 enum dss_feat_id {
 	FEAT_GLOBAL_ALPHA	= 1 << 0,
 	FEAT_GLOBAL_ALPHA_VID1	= 1 << 1,
+	FEAT_PREMUL_ALPHA	= 1 << 2,
 };
 
 /* DSS register field id */
drivers/video/omap2/dss/manager.c +4 -1
index 545e9b9..873b334 100644
@@ -406,6 +406,7 @@ struct overlay_cache_data {
 	u16 out_width;	/* if 0, out_width == width */
 	u16 out_height;	/* if 0, out_height == height */
 	u8 global_alpha;
+	u8 pre_mult_alpha;
 
 	enum omap_channel channel;
 	bool replication;
@@ -842,7 +843,8 @@ static int configure_overlay(enum omap_plane plane)
 			c->rotation_type,
 			c->rotation,
 			c->mirror,
-			c->global_alpha);
+			c->global_alpha,
+			c->pre_mult_alpha);
 
 	if (r) {
 		/* this shouldn't happen */
@@ -1265,6 +1267,7 @@ static int omap_dss_mgr_apply(struct omap_overlay_manager *mgr)
 		oc->out_width = ovl->info.out_width;
 		oc->out_height = ovl->info.out_height;
 		oc->global_alpha = ovl->info.global_alpha;
+		oc->pre_mult_alpha = ovl->info.pre_mult_alpha;
 
 		oc->replication =
 			dss_use_replication(dssdev, ovl->info.color_mode);
drivers/video/omap2/dss/overlay.c +35 -0
index 75642c2..f704d06 100644
@@ -257,6 +257,37 @@ static ssize_t overlay_global_alpha_store(struct omap_overlay *ovl,
 	return size;
 }
 
+static ssize_t overlay_pre_multiplication_alpha_show(struct omap_overlay *ovl,
+		char *buf)
+{
+	return snprintf(buf, PAGE_SIZE, "%d\n",
+			ovl->info.pre_mult_alpha);
+}
+
+static ssize_t overlay_pre_multiplication_alpha_store(struct omap_overlay *ovl,
+		const char *buf, size_t size)
+{
+	int r;
+	struct omap_overlay_info info;
+
+	ovl->get_overlay_info(ovl, &info);
+
+	/* only GFX and Video2 plane support pre alpha multiplication */
+	info.pre_mult_alpha = simple_strtoul(buf, NULL, 10);
+
+	r = ovl->set_overlay_info(ovl, &info);
+	if (r)
+		return r;
+
+	if (ovl->manager) {
+		r = ovl->manager->apply(ovl->manager);
+		if (r)
+			return r;
+	}
+
+	return size;
+}
+
 struct overlay_attribute {
 	struct attribute attr;
 	ssize_t (*show)(struct omap_overlay *, char *);
@@ -280,6 +311,9 @@ static OVERLAY_ATTR(enabled, S_IRUGO|S_IWUSR,
 		overlay_enabled_show, overlay_enabled_store);
 static OVERLAY_ATTR(global_alpha, S_IRUGO|S_IWUSR,
 		overlay_global_alpha_show, overlay_global_alpha_store);
+static OVERLAY_ATTR(pre_multiplication_alpha, S_IRUGO|S_IWUSR,
+		overlay_pre_multiplication_alpha_show,
+		overlay_pre_multiplication_alpha_store);
 
 static struct attribute *overlay_sysfs_attrs[] = {
 	&overlay_attr_name.attr,
@@ -290,6 +324,7 @@ static struct attribute *overlay_sysfs_attrs[] = {
 	&overlay_attr_output_size.attr,
 	&overlay_attr_enabled.attr,
 	&overlay_attr_global_alpha.attr,
+	&overlay_attr_pre_multiplication_alpha.attr,
 	NULL
 };
 
Signature · 1 line
1.5.6.3
#1 lore raw

Hi,

Quoted 11 lines · ext Samreen

From: Rajkumar N <[email protected]>

Enable dss to process color formats with pre-mulitplied alpha. With this we can have alpha values defined for each pixel and hence can have different blending values for each pixel. sysfs entry has been created for this and pre-multiplied alpha support is turned off by default.

Also, the check for '(plane != OMAP_DSS_VIDEO1)' in _dispc_setup_plane has been replaced by the correct dss_has_feature check

You're changing too many things in one patch. Please separate the dss_feature changes and the actual implementation for the pre-multiplied alpha.

Your naming of this feature is also bit varying: you have "pre_mult", "PREMUL", "pre_multiplication_alpha". The last one is quite wrong, as the feature is "premultiplied alpha".

Also a few comments inline.

Quoted 31 lines
---
 arch/arm/plat-omap/include/plat/display.h |    1 +
 drivers/video/omap2/dss/dispc.c           |   25 +++++++++++++++++---
 drivers/video/omap2/dss/dss.h             |    3 +-
 drivers/video/omap2/dss/dss_features.c    |   20 ++++++++++++++--
 drivers/video/omap2/dss/dss_features.h    |    1 +
 drivers/video/omap2/dss/manager.c         |    5 +++-
 drivers/video/omap2/dss/overlay.c         |   35 +++++++++++++++++++++++++++++
 7 files changed, 81 insertions(+), 9 deletions(-)
arch/arm/plat-omap/include/plat/display.h +1 -0
index c915a66..d433baf 100644
@@ -268,6 +268,7 @@ struct omap_overlay_info {
 	u16 out_width;	/* if 0, out_width == width */
 	u16 out_height;	/* if 0, out_height == height */
 	u8 global_alpha;
+	u8 pre_mult_alpha;
 };
 
 struct omap_overlay {
drivers/video/omap2/dss/dispc.c +0 -0
index fa40fa5..f1d1797 100644

drivers/video/omap2/dss/dispc.c static void _dispc_set_vid_size(enum omap_plane plane, int width, int height) · line 782

Quoted 10 lines
drivers/video/omap2/dss/dispc.c +7 -0
@@ -773,6 +773,17 @@ static void _dispc_set_vid_size(enum omap_plane plane, int width, int height)
 	dispc_write_reg(vsi_reg[plane-1], val);
 }
 
+static void _dispc_set_pre_mult_alpha(enum omap_plane plane, bool enable)
+{
+	if (!dss_has_feature(FEAT_PREMUL_ALPHA))
+		return;
+
+	BUG_ON(!dss_has_feature(FEAT_GLOBAL_ALPHA_VID1) &&
+		plane == OMAP_DSS_VIDEO1);

What is the rationale for having the function return, if FEAT_PREMUL_ALPHA is not supported, but BUG if plane is video1 and GLOBAL_ALPHA_VID1 is not supported?

Quoted 163 lines
drivers/video/omap2/dss/dispc.c +14 -4
+
+	REG_FLD_MOD(dispc_reg_att[plane], enable ? 1 : 0, 28, 28);
+}
+
 static void _dispc_setup_global_alpha(enum omap_plane plane, u8 global_alpha)
 {
 	if (!dss_has_feature(FEAT_GLOBAL_ALPHA))
@@ -1507,7 +1518,8 @@ static int _dispc_setup_plane(enum omap_plane plane,
 		bool ilace,
 		enum omap_dss_rotation_type rotation_type,
 		u8 rotation, int mirror,
-		u8 global_alpha)
+		u8 global_alpha,
+		u8 pre_mult_alpha)
 {
 	const int maxdownscale = cpu_is_omap34xx() ? 4 : 2;
 	bool five_taps = 0;
@@ -1693,8 +1705,11 @@ static int _dispc_setup_plane(enum omap_plane plane,
 
 	_dispc_set_rotation_attrs(plane, rotation, mirror, color_mode);
 
-	if (plane != OMAP_DSS_VIDEO1)
+	if ((plane != OMAP_DSS_VIDEO1) ||
+		dss_has_feature(FEAT_GLOBAL_ALPHA_VID1)) {
+		_dispc_set_pre_mult_alpha(plane, pre_mult_alpha);
 		_dispc_setup_global_alpha(plane, global_alpha);
+	}
 
 	return 0;
 }
@@ -3139,7 +3154,8 @@ int dispc_setup_plane(enum omap_plane plane,
 		       enum omap_color_mode color_mode,
 		       bool ilace,
 		       enum omap_dss_rotation_type rotation_type,
-		       u8 rotation, bool mirror, u8 global_alpha)
+		       u8 rotation, bool mirror, u8 global_alpha,
+		       u8 pre_mult_alpha)
 {
 	int r = 0;
 
@@ -3161,7 +3177,8 @@ int dispc_setup_plane(enum omap_plane plane,
 			   color_mode, ilace,
 			   rotation_type,
 			   rotation, mirror,
-			   global_alpha);
+			   global_alpha,
+			   pre_mult_alpha);
 
 	enable_clocks(0);
 
drivers/video/omap2/dss/dss.h +2 -1
index 5c7940d..2bb515c 100644
@@ -359,7 +359,8 @@ int dispc_setup_plane(enum omap_plane plane,
 		      bool ilace,
 		      enum omap_dss_rotation_type rotation_type,
 		      u8 rotation, bool mirror,
-		      u8 global_alpha);
+		      u8 global_alpha,
+		      u8 pre_mult_alpha);
 
 bool dispc_go_busy(enum omap_channel channel);
 void dispc_go(enum omap_channel channel);
drivers/video/omap2/dss/dss_features.c +17 -3
index 867f68d..1abb8c5 100644
@@ -134,7 +134,7 @@ static struct omap_dss_features omap2_dss_features = {
 };
 
 /* OMAP3 DSS Features */
-static struct omap_dss_features omap3_dss_features = {
+static struct omap_dss_features omap3430_dss_features = {
 	.reg_fields = omap3_dss_reg_fields,
 	.num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields),
 
@@ -146,6 +146,18 @@ static struct omap_dss_features omap3_dss_features = {
 	.supported_color_modes = omap3_dss_supported_color_modes,
 };
 
+static struct omap_dss_features omap3630_dss_features = {
+	.reg_fields = omap3_dss_reg_fields,
+	.num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields),
+
+	.has_feature    = FEAT_GLOBAL_ALPHA | FEAT_PREMUL_ALPHA,
+
+	.num_mgrs = 2,
+	.num_ovls = 3,
+	.supported_displays = omap3_dss_supported_displays,
+	.supported_color_modes = omap3_dss_supported_color_modes,
+};
+
 /* Functions returning values related to a DSS feature */
 int dss_feat_get_num_mgrs(void)
 {
@@ -186,6 +198,8 @@ void dss_features_init(void)
 {
 	if (cpu_is_omap24xx())
 		omap_current_dss_features = &omap2_dss_features;
-	else
-		omap_current_dss_features = &omap3_dss_features;
+	else if (cpu_is_omap3630())
+		omap_current_dss_features = &omap3630_dss_features;
+	else if (cpu_is_omap34xx())
+		omap_current_dss_features = &omap3430_dss_features;
 }
drivers/video/omap2/dss/dss_features.h +1 -0
index cb231ea..f287da8 100644
@@ -27,6 +27,7 @@
 enum dss_feat_id {
 	FEAT_GLOBAL_ALPHA	= 1 << 0,
 	FEAT_GLOBAL_ALPHA_VID1	= 1 << 1,
+	FEAT_PREMUL_ALPHA	= 1 << 2,
 };
 
 /* DSS register field id */
drivers/video/omap2/dss/manager.c +4 -1
index 545e9b9..873b334 100644
@@ -406,6 +406,7 @@ struct overlay_cache_data {
 	u16 out_width;	/* if 0, out_width == width */
 	u16 out_height;	/* if 0, out_height == height */
 	u8 global_alpha;
+	u8 pre_mult_alpha;
 
 	enum omap_channel channel;
 	bool replication;
@@ -842,7 +843,8 @@ static int configure_overlay(enum omap_plane plane)
 			c->rotation_type,
 			c->rotation,
 			c->mirror,
-			c->global_alpha);
+			c->global_alpha,
+			c->pre_mult_alpha);
 
 	if (r) {
 		/* this shouldn't happen */
@@ -1265,6 +1267,7 @@ static int omap_dss_mgr_apply(struct omap_overlay_manager *mgr)
 		oc->out_width = ovl->info.out_width;
 		oc->out_height = ovl->info.out_height;
 		oc->global_alpha = ovl->info.global_alpha;
+		oc->pre_mult_alpha = ovl->info.pre_mult_alpha;
 
 		oc->replication =
 			dss_use_replication(dssdev, ovl->info.color_mode);
drivers/video/omap2/dss/overlay.c +6 -0
index 75642c2..f704d06 100644
@@ -257,6 +257,37 @@ static ssize_t overlay_global_alpha_store(struct omap_overlay *ovl,
 	return size;
 }
 
+static ssize_t overlay_pre_multiplication_alpha_show(struct omap_overlay *ovl,
+		char *buf)
+{
+	return snprintf(buf, PAGE_SIZE, "%d\n",
+			ovl->info.pre_mult_alpha);
+}

drivers/video/omap2/dss/overlay.c static ssize_t overlay_global_alpha_store(struct omap_overlay *ovl, · line 275

Quoted 10 lines
drivers/video/omap2/dss/overlay.c +10 -0
+
+static ssize_t overlay_pre_multiplication_alpha_store(struct omap_overlay *ovl,
+		const char *buf, size_t size)
+{
+	int r;
+	struct omap_overlay_info info;
+
+	ovl->get_overlay_info(ovl, &info);
+
+	/* only GFX and Video2 plane support pre alpha multiplication */

Shouldn't you check what the supported features are, instead of having a comment?

Quoted 36 lines
drivers/video/omap2/dss/overlay.c +19 -0
+	info.pre_mult_alpha = simple_strtoul(buf, NULL, 10);
+
+	r = ovl->set_overlay_info(ovl, &info);
+	if (r)
+		return r;
+
+	if (ovl->manager) {
+		r = ovl->manager->apply(ovl->manager);
+		if (r)
+			return r;
+	}
+
+	return size;
+}
+
 struct overlay_attribute {
 	struct attribute attr;
 	ssize_t (*show)(struct omap_overlay *, char *);
@@ -280,6 +311,9 @@ static OVERLAY_ATTR(enabled, S_IRUGO|S_IWUSR,
 		overlay_enabled_show, overlay_enabled_store);
 static OVERLAY_ATTR(global_alpha, S_IRUGO|S_IWUSR,
 		overlay_global_alpha_show, overlay_global_alpha_store);
+static OVERLAY_ATTR(pre_multiplication_alpha, S_IRUGO|S_IWUSR,
+		overlay_pre_multiplication_alpha_show,
+		overlay_pre_multiplication_alpha_store);
 
 static struct attribute *overlay_sysfs_attrs[] = {
 	&overlay_attr_name.attr,
@@ -290,6 +324,7 @@ static struct attribute *overlay_sysfs_attrs[] = {
 	&overlay_attr_output_size.attr,
 	&overlay_attr_enabled.attr,
 	&overlay_attr_global_alpha.attr,
+	&overlay_attr_pre_multiplication_alpha.attr,
 	NULL
 };
 
#2 lore raw

Hi,

Quoted 2 lines · [email protected] wrote:

Alpha Support

[snip]

Quoted 11 lines

drivers/video/omap2/dss/dispc.c static void _dispc_set_vid_size(enum omap_plane plane, int width, int height) · line 782

Quoted 7 lines
drivers/video/omap2/dss/dispc.c +6 -0
+static void _dispc_set_pre_mult_alpha(enum omap_plane plane, bool +enable) {
+	if (!dss_has_feature(FEAT_PREMUL_ALPHA))
+		return;
+
+	BUG_ON(!dss_has_feature(FEAT_GLOBAL_ALPHA_VID1) &&
+		plane == OMAP_DSS_VIDEO1);

What is the rationale for having the function return, if FEAT_PREMUL_ALPHA is not supported, but BUG if plane is video1 and GLOBAL_ALPHA_VID1 is not supported?

Premultiplied alpha is available on omap36xx and above, but on 36xx since global alpha itself isn't supported for video1 then writing to the pre multiplied alpha bit is incorrect.

It could have been possible to make a new feature like FEAT_PRE_MULT_VID1 but I think its redundant as FEAT_GLOBAL_ALPHA_VID1 is enough to determine if we should set the pre multiplied alpha bit for video1 plane or not.

Quoted 200 lines
Quoted 127 lines
drivers/video/omap2/dss/dispc.c +11 -4
+
+	REG_FLD_MOD(dispc_reg_att[plane], enable ? 1 : 0, 28, 28); } +
 static void _dispc_setup_global_alpha(enum omap_plane plane, u8
 	global_alpha)  { if (!dss_has_feature(FEAT_GLOBAL_ALPHA))
@@ -1507,7 +1518,8 @@ static int _dispc_setup_plane(enum omap_plane plane, 
 		bool ilace, enum omap_dss_rotation_type rotation_type,
 		u8 rotation, int mirror,
-		u8 global_alpha)
+		u8 global_alpha,
+		u8 pre_mult_alpha)
 {
 	const int maxdownscale = cpu_is_omap34xx() ? 4 : 2;  	bool five_taps = 0;
@@ -1693,8 +1705,11 @@ static int _dispc_setup_plane(enum omap_plane plane,
 
 	_dispc_set_rotation_attrs(plane, rotation, mirror, color_mode);
 
-	if (plane != OMAP_DSS_VIDEO1)
+	if ((plane != OMAP_DSS_VIDEO1) ||
+		dss_has_feature(FEAT_GLOBAL_ALPHA_VID1)) {
+		_dispc_set_pre_mult_alpha(plane, pre_mult_alpha);
 		_dispc_setup_global_alpha(plane, global_alpha);
+	}
 
 	return 0;
 }
@@ -3139,7 +3154,8 @@ int dispc_setup_plane(enum omap_plane plane,
 		       enum omap_color_mode color_mode,
 		       bool ilace,
 		       enum omap_dss_rotation_type rotation_type,
-		       u8 rotation, bool mirror, u8 global_alpha)
+		       u8 rotation, bool mirror, u8 global_alpha, +		       u8
 pre_mult_alpha) {
 	int r = 0;
 
@@ -3161,7 +3177,8 @@ int dispc_setup_plane(enum omap_plane plane,  			  
 			   color_mode, ilace, rotation_type,
 			   rotation, mirror,
-			   global_alpha);
+			   global_alpha,
+			   pre_mult_alpha);
 
 	enable_clocks(0);
 
(quoted diff) +0 -0

b/drivers/video/omap2/dss/dss.h index 5c7940d..2bb515c 100644

drivers/video/omap2/dss/dss.h +2 -1
@@ -359,7 +359,8 @@ int dispc_setup_plane(enum omap_plane plane,  		     
 		      bool ilace, enum omap_dss_rotation_type rotation_type,
 		      u8 rotation, bool mirror,
-		      u8 global_alpha);
+		      u8 global_alpha,
+		      u8 pre_mult_alpha);
 
 bool dispc_go_busy(enum omap_channel channel);  void dispc_go(enum

omap_channel channel); diff --git
a/drivers/video/omap2/dss/dss_features.c
b/drivers/video/omap2/dss/dss_features.c
index 867f68d..1abb8c5 100644

drivers/video/omap2/dss/dss_features.c +9 -1
@@ -134,7 +134,7 @@ static struct omap_dss_features omap2_dss_features = { 
 }; 
 
 /* OMAP3 DSS Features */
-static struct omap_dss_features omap3_dss_features = {
+static struct omap_dss_features omap3430_dss_features = {
 	.reg_fields = omap3_dss_reg_fields,
 	.num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields),
 
@@ -146,6 +146,18 @@ static struct omap_dss_features omap3_dss_features = {
 	.supported_color_modes = omap3_dss_supported_color_modes,  };
 
+static struct omap_dss_features omap3630_dss_features = {
+	.reg_fields = omap3_dss_reg_fields,
+	.num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields), +
+	.has_feature    = FEAT_GLOBAL_ALPHA | FEAT_PREMUL_ALPHA, +
+	.num_mgrs = 2,
+	.num_ovls = 3,
+	.supported_displays = omap3_dss_supported_displays,
+	.supported_color_modes = omap3_dss_supported_color_modes, }; +
 /* Functions returning values related to a DSS feature */  int

dss_feat_get_num_mgrs(void) { @@ -186,6 +198,8 @@ void

drivers/video/omap2/dss/dss_features.c +0 -2
 	dss_features_init(void)  { if (cpu_is_omap24xx())
 		omap_current_dss_features = &omap2_dss_features;
-	else
-		omap_current_dss_features = &omap3_dss_features; +	else if

(cpu_is_omap3630()) + omap_current_dss_features = &omap3630_dss_features;

drivers/video/omap2/dss/dss_features.c +1 -0
+	else if (cpu_is_omap34xx()) +		omap_current_dss_features =

&omap3430_dss_features; }

drivers/video/omap2/dss/dss_features.h +1 -0
index cb231ea..f287da8 100644
@@ -27,6 +27,7 @@
 enum dss_feat_id {
 	FEAT_GLOBAL_ALPHA	= 1 << 0,
 	FEAT_GLOBAL_ALPHA_VID1	= 1 << 1,
+	FEAT_PREMUL_ALPHA	= 1 << 2,
 };
 
 /* DSS register field id */
drivers/video/omap2/dss/manager.c +3 -1
index 545e9b9..873b334 100644
@@ -406,6 +406,7 @@ struct overlay_cache_data {
 	u16 out_width;	/* if 0, out_width == width */
 	u16 out_height;	/* if 0, out_height == height */
 	u8 global_alpha;
+	u8 pre_mult_alpha;
 
 	enum omap_channel channel;
 	bool replication;
@@ -842,7 +843,8 @@ static int configure_overlay(enum omap_plane plane) 
 			c->rotation_type, c->rotation,
 			c->mirror,
-			c->global_alpha);
+			c->global_alpha,
+			c->pre_mult_alpha);
 
 	if (r) {
 		/* this shouldn't happen */

drivers/video/omap2/dss/manager.c static int omap_dss_mgr_apply(struct · line 1273

Quoted 7 lines
drivers/video/omap2/dss/manager.c +1 -0
@@ -1265,6 +1267,7 @@ static int omap_dss_mgr_apply(struct
 		omap_overlay_manager *mgr) oc->out_width = ovl->info.out_width;
 		oc->out_height = ovl->info.out_height;
 		oc->global_alpha = ovl->info.global_alpha;
+		oc->pre_mult_alpha = ovl->info.pre_mult_alpha;
 
 		oc->replication =
 			dss_use_replication(dssdev,

ovl->info.color_mode); diff --git

drivers/video/omap2/dss/overlay.c static ssize_t

Quoted 6 lines

a/drivers/video/omap2/dss/overlay.c
b/drivers/video/omap2/dss/overlay.c
index 75642c2..f704d06 100644

drivers/video/omap2/dss/overlay.c +0 -0
@@ -257,6 +257,37 @@ static ssize_t

overlay_global_alpha_store(struct omap_overlay *ovl,

drivers/video/omap2/dss/overlay.c static ssize_t overlay_global_alpha_store(struct omap_overlay *ovl,

Quoted 4 lines
drivers/video/omap2/dss/overlay.c +1 -0
 	return size;
 }
 
+static ssize_t

overlay_pre_multiplication_alpha_show(struct omap_overlay *ovl,

drivers/video/omap2/dss/overlay.c static ssize_t overlay_global_alpha_store(struct omap_overlay *ovl,

Quoted 7 lines
drivers/video/omap2/dss/overlay.c +7 -0
+		char *buf)
+{
+	return snprintf(buf, PAGE_SIZE, "%d\n",
+			ovl->info.pre_mult_alpha);
+}
+
+static ssize_t

overlay_pre_multiplication_alpha_store(struct omap_overlay *ovl,

drivers/video/omap2/dss/overlay.c static ssize_t overlay_global_alpha_store(struct omap_overlay *ovl, · line 275

Quoted 8 lines
drivers/video/omap2/dss/overlay.c +8 -0
+		const char *buf, size_t size)
+{
+	int r;
+	struct omap_overlay_info info;
+
+	ovl->get_overlay_info(ovl, &info);
+
+	/* only GFX and Video2 plane support pre alpha multiplication */

Shouldn't you check what the supported features are, instead of having a comment?

Quoted 33 lines
drivers/video/omap2/dss/overlay.c +14 -0
+	info.pre_mult_alpha = simple_strtoul(buf, NULL, 10); +
+	r = ovl->set_overlay_info(ovl, &info);
+	if (r)
+		return r;
+
+	if (ovl->manager) {
+		r = ovl->manager->apply(ovl->manager);
+		if (r)
+			return r;
+	}
+
+	return size;
+}
+
 struct overlay_attribute {
 	struct attribute attr;
 	ssize_t (*show)(struct omap_overlay *, char *); @@ -280,6 +311,9 @@

static OVERLAY_ATTR(enabled, S_IRUGO|S_IWUSR,
overlay_enabled_show, overlay_enabled_store); static
OVERLAY_ATTR(global_alpha, S_IRUGO|S_IWUSR,

drivers/video/omap2/dss/overlay.c +3 -0
 		overlay_global_alpha_show, overlay_global_alpha_store);
+static OVERLAY_ATTR(pre_multiplication_alpha, S_IRUGO|S_IWUSR,
+		overlay_pre_multiplication_alpha_show,
+		overlay_pre_multiplication_alpha_store);
 
 static struct attribute *overlay_sysfs_attrs[] = { 

&overlay_attr_name.attr, @@ -290,6 +324,7 @@ static struct attribute

drivers/video/omap2/dss/overlay.c +1 -0
 	*overlay_sysfs_attrs[] = { &overlay_attr_output_size.attr,
 	&overlay_attr_enabled.attr,
 	&overlay_attr_global_alpha.attr,
+	&overlay_attr_pre_multiplication_alpha.attr,
 	NULL
 };
#3 lore raw
Quoted 20 lines · Archit

Hi,

Quoted 2 lines · [email protected] wrote:

Alpha Support

[snip]

Quoted 11 lines

drivers/video/omap2/dss/dispc.c static void _dispc_set_vid_size(enum omap_plane plane, int width, int height) · line 782

Quoted 7 lines
drivers/video/omap2/dss/dispc.c +6 -0
+static void _dispc_set_pre_mult_alpha(enum omap_plane plane, bool +enable) {
+	if (!dss_has_feature(FEAT_PREMUL_ALPHA))
+		return;
+
+	BUG_ON(!dss_has_feature(FEAT_GLOBAL_ALPHA_VID1) &&
+		plane == OMAP_DSS_VIDEO1);

What is the rationale for having the function return, if FEAT_PREMUL_ALPHA is not supported, but BUG if plane is video1 and GLOBAL_ALPHA_VID1 is not supported?

Quoted 7 lines

Premultiplied alpha is available on omap36xx and above, but on 36xx since global alpha itself isn't supported for video1 then writing to the pre multiplied alpha bit is incorrect.

It could have been possible to make a new feature like FEAT_PRE_MULT_VID1 but I think its redundant as FEAT_GLOBAL_ALPHA_VID1 is enough to determine if we should set the pre multiplied alpha bit for video1 plane or not.

I was referring to the first check using return, and the second using BUG(). If nobody is supposed to call that function when

!dss_has_feature(FEAT_GLOBAL_ALPHA_VID1) && plane == OMAP_DSS_VIDEO1)

then why is it ok to call that function when

!dss_has_feature(FEAT_PREMUL_ALPHA)

Shouldn't they both be either returns or BUGs?

Tomi

#4 lore raw

Hi,

Quoted 33 lines · Tomi Valkeinen
Quoted 20 lines · Archit

Hi,

Quoted 2 lines · [email protected] wrote:

Alpha Support

[snip]

Quoted 11 lines

drivers/video/omap2/dss/dispc.c static void _dispc_set_vid_size(enum omap_plane plane, int width, int height) · line 782

Quoted 7 lines
drivers/video/omap2/dss/dispc.c +6 -0
+static void _dispc_set_pre_mult_alpha(enum omap_plane plane, bool
+enable) { +	if (!dss_has_feature(FEAT_PREMUL_ALPHA))
+		return;
+
+	BUG_ON(!dss_has_feature(FEAT_GLOBAL_ALPHA_VID1) &&
+		plane == OMAP_DSS_VIDEO1);

What is the rationale for having the function return, if FEAT_PREMUL_ALPHA is not supported, but BUG if plane is video1 and GLOBAL_ALPHA_VID1 is not supported?

Quoted 7 lines

Premultiplied alpha is available on omap36xx and above, but on 36xx since global alpha itself isn't supported for video1 then writing to the pre multiplied alpha bit is incorrect.

It could have been possible to make a new feature like FEAT_PRE_MULT_VID1 but I think its redundant as FEAT_GLOBAL_ALPHA_VID1 is enough to determine if we should set the pre multiplied

alpha bit for video1 plane or not.

I was referring to the first check using return, and the second using BUG(). If nobody is supposed to call that function when

Quoted 8 lines

!dss_has_feature(FEAT_GLOBAL_ALPHA_VID1) && plane == OMAP_DSS_VIDEO1)

then why is it ok to call that function when

!dss_has_feature(FEAT_PREMUL_ALPHA)

Shouldn't they both be either returns or BUGs?

If you see the current code, _dispc_setup_global_alpha() does the same thing, and in the call to it in _dispc_setup_plane() is:

...
...

	if (plane != OMAP_DSS_VIDEO1)
		_dispc_setup_global_alpha(plane, global_alpha);

...
...

So, I guess this BUG_ON is probably not required for both setup_global_alpha and setup_pre_multiplied_alpha if you take care while calling these functions from _dispc_setup_plane().

But this is the same with _dispc_set_scaling(), _dispc_set_vid_size() etc where we have a BUG_ON(plane == OMAP_DSS_GFX) even when we take care of not calling it for the GFX pipe.

Archit

#5 lore raw

Hi,

Quoted 57 lines · Archit

Hi,

Quoted 33 lines · Tomi Valkeinen
Quoted 19 lines · Archit

Hi,

Quoted 2 lines · [email protected] wrote:

Alpha Support

[snip]

Quoted 10 lines

drivers/video/omap2/dss/dispc.c static void _dispc_set_vid_size(enum omap_plane plane, int width, int height) · line 782

Quoted 6 lines
drivers/video/omap2/dss/dispc.c +5 -0
+static void _dispc_set_pre_mult_alpha(enum omap_plane plane, bool
+enable) { +	if (!dss_has_feature(FEAT_PREMUL_ALPHA)) +		return;
+
+	BUG_ON(!dss_has_feature(FEAT_GLOBAL_ALPHA_VID1) &&
+		plane == OMAP_DSS_VIDEO1);

What is the rationale for having the function return, if FEAT_PREMUL_ALPHA is not supported, but BUG if plane is video1 and GLOBAL_ALPHA_VID1 is not supported?

Quoted 8 lines

Premultiplied alpha is available on omap36xx and above, but on 36xx since global alpha itself isn't supported for video1 then writing to the pre multiplied alpha bit is incorrect.

It could have been possible to make a new feature like FEAT_PRE_MULT_VID1 but I think its redundant as FEAT_GLOBAL_ALPHA_VID1 is enough to determine if we should set the pre multiplied

alpha bit for video1 plane or not.

I was referring to the first check using return, and the second using BUG(). If nobody is supposed to call that function when

Quoted 8 lines

!dss_has_feature(FEAT_GLOBAL_ALPHA_VID1) && plane == OMAP_DSS_VIDEO1)

then why is it ok to call that function when

!dss_has_feature(FEAT_PREMUL_ALPHA)

Shouldn't they both be either returns or BUGs?

If you see the current code, _dispc_setup_global_alpha() does the same thing, and in the call to it in _dispc_setup_plane() is:

...
...

	if (plane != OMAP_DSS_VIDEO1)
		_dispc_setup_global_alpha(plane, global_alpha); ... ...

So, I guess this BUG_ON is probably not required for both setup_global_alpha and setup_pre_multiplied_alpha if you take care while calling these functions from _dispc_setup_plane().

Quoted 6 lines

But this is the same with _dispc_set_scaling(), _dispc_set_vid_size() etc where we have a BUG_ON(plane == OMAP_DSS_GFX) even when we take care of not calling it for the GFX pipe.

Archit

[Samreen]
If this clarification is aligned, should I go ahead and post the patch
with the remaining review comments

Regards,
Samreen

#6 lore raw
In reply to Taneja, Archit
Quoted 50 lines · Archit

Hi,

Quoted 33 lines · Tomi Valkeinen
Quoted 20 lines · Archit

Hi,

Quoted 2 lines · [email protected] wrote:

Alpha Support

[snip]

Quoted 11 lines

drivers/video/omap2/dss/dispc.c static void _dispc_set_vid_size(enum omap_plane plane, int width, int height) · line 782

Quoted 7 lines
drivers/video/omap2/dss/dispc.c +6 -0
+static void _dispc_set_pre_mult_alpha(enum omap_plane plane, bool
+enable) { +	if (!dss_has_feature(FEAT_PREMUL_ALPHA))
+		return;
+
+	BUG_ON(!dss_has_feature(FEAT_GLOBAL_ALPHA_VID1) &&
+		plane == OMAP_DSS_VIDEO1);

What is the rationale for having the function return, if FEAT_PREMUL_ALPHA is not supported, but BUG if plane is video1 and GLOBAL_ALPHA_VID1 is not supported?

Quoted 7 lines

Premultiplied alpha is available on omap36xx and above, but on 36xx since global alpha itself isn't supported for video1 then writing to the pre multiplied alpha bit is incorrect.

It could have been possible to make a new feature like FEAT_PRE_MULT_VID1 but I think its redundant as FEAT_GLOBAL_ALPHA_VID1 is enough to determine if we should set the pre multiplied

alpha bit for video1 plane or not.

I was referring to the first check using return, and the second using BUG(). If nobody is supposed to call that function when

Quoted 8 lines

!dss_has_feature(FEAT_GLOBAL_ALPHA_VID1) && plane == OMAP_DSS_VIDEO1)

then why is it ok to call that function when

!dss_has_feature(FEAT_PREMUL_ALPHA)

Shouldn't they both be either returns or BUGs?

If you see the current code, _dispc_setup_global_alpha() does the same thing, and in the call to it in _dispc_setup_plane() is:

...
...

Quoted 8 lines
	if (plane != OMAP_DSS_VIDEO1)
		_dispc_setup_global_alpha(plane, global_alpha);

...
...

So, I guess this BUG_ON is probably not required for both setup_global_alpha and setup_pre_multiplied_alpha if you take care while calling these functions from _dispc_setup_plane().

BUGs should be used exactly in those cases, where you are sure you're always calling the function with right parameters. BUGs are never meant to trigger, so they should be used as a safeguard against broken changes.

Quoted 3 lines

But this is the same with _dispc_set_scaling(), _dispc_set_vid_size() etc where we have a BUG_ON(plane == OMAP_DSS_GFX) even when we take care of not calling it for the GFX pipe.

Yes, I'm sure there are functions that are not perfect =).

So to summarize: if _dispc_set_pre_mult_alpha() is only called from inside DSS, and it will never be called with a wrong plane argument, then it should only use BUGs, not return.

Now, the question is, is it better to do the argument checking in the caller or in the callee? In the case of DSS internal functions it's perhaps easier if the callee does the checking. So:

_dispc_setup_plane() should always call _dispc_setup_global_alpha(), as future OMAP versions may support global alpha on any overlay, and I don't think it's _dispc_setup_plane's job to do that check as the checks may be lenghty.

_dispc_setup_global_alpha() would do the check if global_alpha is supported on that plane, and do nothing if not (or, return an error, which _dispc_setup_plane() would ignore, but I don't think that's needed).

And similarly for premult alpha. And I'm not saying all these have to be changed now, but as general thoughts about the matter.

Tomi