All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
To: linux-media@vger.kernel.org
Cc: sakari.ailus@linux.intel.com, bingbu.cao@intel.com,
	laurent.pinchart@ideasonboard.com,
	Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Subject: [RFC PATCH] media: staging: ipu3-imgu: add the AWB memory layout
Date: Tue, 31 Aug 2021 20:51:40 +0200	[thread overview]
Message-ID: <20210831185140.77400-1-jeanmichel.hautbois@ideasonboard.com> (raw)

While parsing the RAW AWB metadata, the AWB layout was missing to fully
understand which byte corresponds to which feature. Make the field names
and usage explicit, as it is used by the userspace applications.

Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
---
This structure layout is defined in CrOs:
https://chromium.googlesource.com/chromiumos/platform/arc-camera/+/refs/heads/master/hal/intel/include/ia_imaging/awb_public.h

There are a few things not really understood right now:
- Is sat_ratio a full scale ratio (I can't get more than some values out
  of it, is it a ratio of 25%, 50%, 75%, 100% ?)
- What are the real minimum and maximum values for the grid size ? From
  CrOs it appears to be [16, 80] for width and [16, 60] for height while
  in this file it seems to be [16, 160] for width and not really defined
  for height AFAICT ?
- Same for the block_width_log2 and block_height_log2 which are [3, 7]
  in this file and [3, 6] in the awb_public.h header ?

 .../media/ipu3/include/uapi/intel-ipu3.h      | 38 ++++++++++++++-----
 1 file changed, 29 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/media/ipu3/include/uapi/intel-ipu3.h b/drivers/staging/media/ipu3/include/uapi/intel-ipu3.h
index fa3d6ee5adf2..83191aff2ddd 100644
--- a/drivers/staging/media/ipu3/include/uapi/intel-ipu3.h
+++ b/drivers/staging/media/ipu3/include/uapi/intel-ipu3.h
@@ -61,20 +61,40 @@ struct ipu3_uapi_grid_config {
 	__u16 y_end;
 } __packed;
 
+/**
+ * struct ipu3_uapi_awb_raw_buffer - Memory layout for each cell in AWB
+ *
+ * @Gr_avg:	Green average for red lines in the cell.
+ * @R_avg:	Red average in the cell.
+ * @B_avg:	Blue average in the cell.
+ * @Gb_avg:	Green average for blue lines in the cell.
+ * @sat_ratio:  Saturation ratio in the cell.
+ * @padding0:   Unused byte for padding.
+ * @padding1:   Unused byte for padding.
+ * @padding2:   Unused byte for padding.
+ */
+struct ipu3_uapi_awb_raw_buffer {
+    unsigned char Gr_avg;
+    unsigned char R_avg;
+    unsigned char B_avg;
+    unsigned char Gb_avg;
+    unsigned char sat_ratio;
+    unsigned char padding0;
+    unsigned char padding1;
+    unsigned char padding2;
+} __packed;
+
 /*
  * The grid based data is divided into "slices" called set, each slice of setX
  * refers to ipu3_uapi_grid_config width * height_per_slice.
  */
 #define IPU3_UAPI_AWB_MAX_SETS				60
-/* Based on grid size 80 * 60 and cell size 16 x 16 */
-#define IPU3_UAPI_AWB_SET_SIZE				1280
-#define IPU3_UAPI_AWB_MD_ITEM_SIZE			8
-#define IPU3_UAPI_AWB_SPARE_FOR_BUBBLES \
-	(IPU3_UAPI_MAX_BUBBLE_SIZE * IPU3_UAPI_MAX_STRIPES * \
-	 IPU3_UAPI_AWB_MD_ITEM_SIZE)
+#define AWB_PUBLIC_NUM_OF_ITEMS_IN_SET			160
+/* Based on max grid height + Spare for bubbles */
+#define AWB_PUBLIC_NUM_OF_SETS_IN_BUFFER IPU3_UAPI_AWB_MAX_SETS + \
+	(IPU3_UAPI_MAX_BUBBLE_SIZE * IPU3_UAPI_MAX_STRIPES)
 #define IPU3_UAPI_AWB_MAX_BUFFER_SIZE \
-	(IPU3_UAPI_AWB_MAX_SETS * \
-	 (IPU3_UAPI_AWB_SET_SIZE + IPU3_UAPI_AWB_SPARE_FOR_BUBBLES))
+        AWB_PUBLIC_NUM_OF_SETS_IN_BUFFER * AWB_PUBLIC_NUM_OF_ITEMS_IN_SET
 
 /**
  * struct ipu3_uapi_awb_raw_buffer - AWB raw buffer
@@ -83,7 +103,7 @@ struct ipu3_uapi_grid_config {
  *		the average values for each color channel.
  */
 struct ipu3_uapi_awb_raw_buffer {
-	__u8 meta_data[IPU3_UAPI_AWB_MAX_BUFFER_SIZE]
+	struct ipu3_uapi_awb_raw_buffer meta_data[IPU3_UAPI_AWB_MAX_BUFFER_SIZE]
 		__attribute__((aligned(32)));
 } __packed;
 
-- 
2.30.2


             reply	other threads:[~2021-08-31 18:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-31 18:51 Jean-Michel Hautbois [this message]
2021-08-31 21:33 ` [RFC PATCH] media: staging: ipu3-imgu: add the AWB memory layout Laurent Pinchart
2021-09-08  8:17   ` Laurent Pinchart
2021-09-09  2:19     ` Bingbu Cao
2021-09-09  5:52       ` Jean-Michel Hautbois
2021-09-21 11:33         ` Laurent Pinchart
2021-09-01  1:00 ` kernel test robot
2021-09-01  1:00   ` kernel test robot
2021-09-01  2:35 ` kernel test robot
2021-09-21 11:29 ` Laurent Pinchart

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=20210831185140.77400-1-jeanmichel.hautbois@ideasonboard.com \
    --to=jeanmichel.hautbois@ideasonboard.com \
    --cc=bingbu.cao@intel.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    /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.