All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: linux-media@vger.kernel.org
Cc: sakari.ailus@iki.fi
Subject: [PATCH v3 6/9] omap3isp: preview: Remove update_attrs feature_bit field
Date: Mon, 16 Apr 2012 15:29:51 +0200	[thread overview]
Message-ID: <1334582994-6967-7-git-send-email-laurent.pinchart@ideasonboard.com> (raw)
In-Reply-To: <1334582994-6967-1-git-send-email-laurent.pinchart@ideasonboard.com>

The feature_bit is always equal to 1 << array position, remove it and
compute the value dynamically.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/media/video/omap3isp/isppreview.c |  107 +++++++++++++++--------------
 1 files changed, 54 insertions(+), 53 deletions(-)

diff --git a/drivers/media/video/omap3isp/isppreview.c b/drivers/media/video/omap3isp/isppreview.c
index da031c1..c487995 100644
--- a/drivers/media/video/omap3isp/isppreview.c
+++ b/drivers/media/video/omap3isp/isppreview.c
@@ -723,70 +723,71 @@ preview_config_yc_range(struct isp_prev_device *prev, const void *yclimit)
 
 /* preview parameters update structure */
 struct preview_update {
-	int feature_bit;
 	void (*config)(struct isp_prev_device *, const void *);
 	void (*enable)(struct isp_prev_device *, u8);
 	bool skip;
 };
 
+/* Keep the array indexed by the OMAP3ISP_PREV_* bit number. */
 static struct preview_update update_attrs[] = {
-	{OMAP3ISP_PREV_LUMAENH,
+	/* OMAP3ISP_PREV_LUMAENH */ {
 		preview_config_luma_enhancement,
-		preview_enable_luma_enhancement},
-	{OMAP3ISP_PREV_INVALAW,
+		preview_enable_luma_enhancement,
+	}, /* OMAP3ISP_PREV_INVALAW */ {
 		NULL,
-		preview_enable_invalaw},
-	{OMAP3ISP_PREV_HRZ_MED,
+		preview_enable_invalaw,
+	}, /* OMAP3ISP_PREV_HRZ_MED */ {
 		preview_config_hmed,
-		preview_enable_hmed},
-	{OMAP3ISP_PREV_CFA,
+		preview_enable_hmed,
+	}, /* OMAP3ISP_PREV_CFA */ {
 		preview_config_cfa,
-		preview_enable_cfa},
-	{OMAP3ISP_PREV_CHROMA_SUPP,
+		preview_enable_cfa,
+	}, /* OMAP3ISP_PREV_CHROMA_SUPP */ {
 		preview_config_chroma_suppression,
-		preview_enable_chroma_suppression},
-	{OMAP3ISP_PREV_WB,
+		preview_enable_chroma_suppression,
+	}, /* OMAP3ISP_PREV_WB */ {
 		preview_config_whitebalance,
-		NULL},
-	{OMAP3ISP_PREV_BLKADJ,
+		NULL,
+	}, /* OMAP3ISP_PREV_BLKADJ */ {
 		preview_config_blkadj,
-		NULL},
-	{OMAP3ISP_PREV_RGB2RGB,
+		NULL,
+	}, /* OMAP3ISP_PREV_RGB2RGB */ {
 		preview_config_rgb_blending,
-		NULL},
-	{OMAP3ISP_PREV_COLOR_CONV,
+		NULL,
+	}, /* OMAP3ISP_PREV_COLOR_CONV */ {
 		preview_config_rgb_to_ycbcr,
-		NULL},
-	{OMAP3ISP_PREV_YC_LIMIT,
+		NULL,
+	}, /* OMAP3ISP_PREV_YC_LIMIT */ {
 		preview_config_yc_range,
-		NULL},
-	{OMAP3ISP_PREV_DEFECT_COR,
+		NULL,
+	}, /* OMAP3ISP_PREV_DEFECT_COR */ {
 		preview_config_dcor,
-		preview_enable_dcor},
-	{OMAP3ISP_PREV_GAMMABYPASS,
+		preview_enable_dcor,
+	}, /* OMAP3ISP_PREV_GAMMABYPASS */ {
 		NULL,
-		preview_enable_gammabypass},
-	{OMAP3ISP_PREV_DRK_FRM_CAPTURE,
+		preview_enable_gammabypass,
+	}, /* OMAP3ISP_PREV_DRK_FRM_CAPTURE */ {
 		NULL,
-		preview_enable_drkframe_capture},
-	{OMAP3ISP_PREV_DRK_FRM_SUBTRACT,
+		preview_enable_drkframe_capture,
+	}, /* OMAP3ISP_PREV_DRK_FRM_SUBTRACT */ {
 		NULL,
-		preview_enable_drkframe},
-	{OMAP3ISP_PREV_LENS_SHADING,
+		preview_enable_drkframe,
+	}, /* OMAP3ISP_PREV_LENS_SHADING */ {
 		preview_config_drkf_shadcomp,
-		preview_enable_drkframe},
-	{OMAP3ISP_PREV_NF,
+		preview_enable_drkframe,
+	}, /* OMAP3ISP_PREV_NF */ {
 		preview_config_noisefilter,
-		preview_enable_noisefilter},
-	{OMAP3ISP_PREV_GAMMA,
+		preview_enable_noisefilter,
+	}, /* OMAP3ISP_PREV_GAMMA */ {
 		preview_config_gammacorrn,
-		NULL},
-	{OMAP3ISP_PREV_CONTRAST,
+		NULL,
+	}, /* OMAP3ISP_PREV_CONTRAST */ {
 		preview_config_contrast,
-		NULL, true},
-	{OMAP3ISP_PREV_BRIGHTNESS,
+		NULL, true,
+	}, /* OMAP3ISP_PREV_BRIGHTNESS */ {
 		preview_config_brightness,
-		NULL, true},
+		NULL, true,
+	},
 };
 
 /*
@@ -903,30 +904,28 @@ static int preview_config(struct isp_prev_device *prev,
 
 	for (i = 0; i < ARRAY_SIZE(update_attrs); i++) {
 		attr = &update_attrs[i];
-		bit = 0;
+		bit = 1 << i;
 
-		if (attr->skip || !(cfg->update & attr->feature_bit))
+		if (attr->skip || !(cfg->update & bit))
 			continue;
 
-		bit = cfg->flag & attr->feature_bit;
-		if (bit) {
+		if (cfg->flag & bit) {
 			void *to = NULL, __user *from = NULL;
 			unsigned long sz = 0;
 
-			sz = __preview_get_ptrs(params, &to, cfg, &from,
-						   bit);
+			sz = __preview_get_ptrs(params, &to, cfg, &from, bit);
 			if (to && from && sz) {
 				if (copy_from_user(to, from, sz)) {
 					rval = -EFAULT;
 					break;
 				}
 			}
-			params->features |= attr->feature_bit;
+			params->features |= bit;
 		} else {
-			params->features &= ~attr->feature_bit;
+			params->features &= ~bit;
 		}
 
-		prev->update |= attr->feature_bit;
+		prev->update |= bit;
 	}
 
 	prev->shadow_update = 0;
@@ -943,7 +942,8 @@ static void preview_setup_hw(struct isp_prev_device *prev)
 {
 	struct prev_params *params = &prev->params;
 	struct preview_update *attr;
-	int i, bit;
+	unsigned int bit;
+	unsigned int i;
 	void *param_ptr;
 
 	if (prev->update == 0)
@@ -951,11 +951,12 @@ static void preview_setup_hw(struct isp_prev_device *prev)
 
 	for (i = 0; i < ARRAY_SIZE(update_attrs); i++) {
 		attr = &update_attrs[i];
+		bit = 1 << i;
 
-		if (!(prev->update & attr->feature_bit))
+		if (!(prev->update & bit))
 			continue;
-		bit = params->features & attr->feature_bit;
-		if (bit) {
+
+		if (params->features & bit) {
 			if (attr->config) {
 				__preview_get_ptrs(params, &param_ptr, NULL,
 						      NULL, bit);
@@ -967,7 +968,7 @@ static void preview_setup_hw(struct isp_prev_device *prev)
 			if (attr->enable)
 				attr->enable(prev, 0);
 
-		prev->update &= ~attr->feature_bit;
+		prev->update &= ~bit;
 	}
 }
 
-- 
1.7.3.4


  parent reply	other threads:[~2012-04-16 13:29 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-16 13:29 [PATCH v3 0/9] OMAP3 ISP preview engine configuration improvement Laurent Pinchart
2012-04-16 13:29 ` [PATCH v3 1/9] omap3isp: preview: Skip brightness and contrast in configuration ioctl Laurent Pinchart
2012-04-16 13:29 ` [PATCH v3 2/9] omap3isp: preview: Optimize parameters setup for the common case Laurent Pinchart
2012-04-16 17:03   ` Sakari Ailus
2012-04-16 13:29 ` [PATCH v3 3/9] omap3isp: preview: Remove averager parameter update flag Laurent Pinchart
2012-04-16 13:29 ` [PATCH v3 4/9] omap3isp: preview: Remove unused isptables_update structure definition Laurent Pinchart
2012-04-16 13:29 ` [PATCH v3 5/9] omap3isp: preview: Merge configuration and feature bits Laurent Pinchart
2012-04-16 17:08   ` Sakari Ailus
2012-04-16 13:29 ` Laurent Pinchart [this message]
2012-04-16 18:00   ` [PATCH v3 6/9] omap3isp: preview: Remove update_attrs feature_bit field Sakari Ailus
2012-04-16 13:29 ` [PATCH v3 7/9] omap3isp: preview: Rename prev_params fields to match userspace API Laurent Pinchart
2012-04-16 18:46   ` Sakari Ailus
2012-04-16 13:29 ` [PATCH v3 8/9] omap3isp: preview: Simplify configuration parameters access Laurent Pinchart
2012-04-16 20:01   ` Sakari Ailus
2012-04-16 13:29 ` [PATCH v3 9/9] omap3isp: preview: Shorten shadow update delay Laurent Pinchart
2012-04-17 14:26   ` Sakari Ailus
2012-04-17 16:09     ` Laurent Pinchart
2012-04-17 18:41       ` Sakari Ailus

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=1334582994-6967-7-git-send-email-laurent.pinchart@ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=sakari.ailus@iki.fi \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.