From: Jerry-ch Chen <Jerry-ch.Chen@mediatek.com>
To: Tomasz Figa <tfiga@chromium.org>
Cc: "laurent.pinchart+renesas@ideasonboard.com"
<laurent.pinchart+renesas@ideasonboard.com>,
"Rynn Wu (吳育恩)" <Rynn.Wu@mediatek.com>,
"Po-Yang Huang (黃柏陽)" <po-yang.huang@mediatek.com>,
"suleiman@chromium.org" <suleiman@chromium.org>,
jerry-ch.chen@mediatek.com,
"Jungo Lin (林明俊)" <jungo.lin@mediatek.com>,
"hans.verkuil@cisco.com" <hans.verkuil@cisco.com>,
"Sakari Ailus" <sakari.ailus@iki.fi>,
"Frederic Chen (陳俊元)" <Frederic.Chen@mediatek.com>,
"linux-media@vger.kernel.org" <linux-media@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"Sj Huang (黃信璋)" <sj.huang@mediatek.com>,
"yuzhao@chromium.org" <yuzhao@chromium.org>,
"linux-mediatek@lists.infradead.org"
<linux-mediatek@lists.infradead.org>,
"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
"mchehab@kernel.org" <mchehab@kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"Sean Cheng (鄭昇弘)" <Sean.Cheng@mediatek.com>,
srv_heupstream <srv_heupstream@mediatek.com>,
"shik@chromium.org" <shik@chromium.org>,
"Christie Yu (游雅惠)" <christie.yu@mediatek.com>,
"zwisler@chromium.org" <zwisler@chromium.org>,
"Hans Verkuil" <hverkuil-cisco@xs4all.nl>,
"Enrico Weigelt, metux IT consult" <lkml@metux.net>
Subject: Re: [RFC PATCH V2 4/4] platform: mtk-isp: Add Mediatek FD driver
Date: Mon, 29 Jul 2019 19:58:11 +0800 [thread overview]
Message-ID: <1564401491.15267.405.camel@mtksdccf07> (raw)
In-Reply-To: <CAAFQd5A0Qi==m4O9L2W3Qmdx4g8acs-kjBtHjLBNCBpoGd5ZSw@mail.gmail.com>
Hi Tomasz,
On Mon, 2019-07-29 at 17:57 +0800, Tomasz Figa wrote:
> On Mon, Jul 29, 2019 at 3:01 PM Jerry-ch Chen
> <Jerry-ch.Chen@mediatek.com> wrote:
> >
> > Hi Enrico,
> >
> > On Tue, 2019-07-09 at 18:56 +0800, Enrico Weigelt, metux IT consult
> > wrote:
> > > On 09.07.19 10:41, Jerry-ch Chen wrote:
> > >
> > > Hi,
> > >
> > >
> > > > diff --git a/drivers/media/platform/mtk-isp/fd/mtk_fd.h b/drivers/media/platform/mtk-isp/fd/mtk_fd.h
> > > > new file mode 100644
> > > > index 0000000..289999b
> > > > --- /dev/null
> > > > +++ b/drivers/media/platform/mtk-isp/fd/mtk_fd.h
> > > > @@ -0,0 +1,157 @@
> > > > +/* SPDX-License-Identifier: GPL-2.0 */
> > > > +//
> > > > +// Copyright (c) 2018 MediaTek Inc.
> > > > +
> > > > +#ifndef __MTK_FD_HW_H__
> > > > +#define __MTK_FD_HW_H__
> > > > +
> > > > +#include <linux/io.h>
> > > > +#include <linux/types.h>
> > > > +#include <linux/platform_device.h>
> > > > +#include <media/v4l2-ctrls.h>
> > > > +#include <media/v4l2-device.h>
> > > > +#include <media/videobuf2-v4l2.h>
> > > > +
> > > > +#define MTK_FD_OUTPUT_MIN_WIDTH 26U
> > > > +#define MTK_FD_OUTPUT_MIN_HEIGHT 26U
> > > > +#define MTK_FD_OUTPUT_MAX_WIDTH 640U
> > > > +#define MTK_FD_OUTPUT_MAX_HEIGHT 480U
> > > > +
> > > > +/* Control the user defined image widths and heights
> > > > + * to be scaled and performed face detection in FD HW.
> > > > + * MTK FD support up to 14 user defined image sizes to perform face detection.
> > > > + */
> > > > +#define V4L2_CID_MTK_FD_SCALE_IMG_WIDTH (V4L2_CID_USER_MTK_FD_BASE + 1)
> > > > +#define V4L2_CID_MTK_FD_SCALE_IMG_HEIGHT (V4L2_CID_USER_MTK_FD_BASE + 2)
> > >
> > > I've got a *really* bad feeling about introducing chip specific
> > > uapi stuff. (by the way: uapi stuff belongs into include/uapi/...)
> > >
> > Thanks for your comments,
> >
> > If we remain chip-specific control IDs, I will move the uapi stuff into
> > inlcude/uapi/mtk_fd.h (filename TBD)
> >
> > > Maybe you could tell us what that's *really* about, so we can find some
> > > standard / chip-independent api for these things. That's one of the
> > > major point of the kernel: hardware abstraction.
> > >
> > I am not sure if it is possible for us to add some standard
> > v4l2-controls for face detection, a further explanations of controls are
> > listed below.
> >
> > In v4l2-controls, there exists V4L2_CID_DETECT_CLASS, but I haven't
> > found the standards or api that can be used for face detection yet.
> > https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/v4l2-controls.h#L1092
> >
> > For detecting certain face angle and head direction, we would need
> > V4L2_CID_DETECT_ANGLE, V4L2_CID_DETECT_DIRECTION controls for user to
> > specify the angle and direction to be detected.
> > In MTK FD driver, we support the following angles and directions to be
> > selected by user, and they are both multiple selected .
> > FD_angle_table[] = {-90, -45, 0 , 45, 90}
> > FD_direction_table[] = {0, 30, 60, 90, 120, 150, ..., 330}
> >
> > Assuming these v4l2-controls are array of V4L2_CTRL_TYPE_U16 with
> > dimension 5 and 12.
> > User can select the desired angle and directions to be detected into
> > arrays and bring it to driver by these controls, however, the more they
> > select, the longer execution time needed by HW.
> >
>
> Sounds like we need some kind of a menu bitmask control here, but I
> don't see V4L2 having anything like that.
>
> Hans, Sakari, any ideas?
>
> > For detecting different sizes of faces and increase the detection speed,
> > FD driver might need to scales down the input image into different
> > smaller sizes
>
> Do you mean the FD hardware would do the scaling or the driver code
> itself? It would be undesirable to do such scaling in a kernel driver,
> so if that's not something handled by the hardware, the downscaled
> image might need to be provided from the userspace.
>
Thanks for your comments.
Yes, FD hardware will do the scaling itself, so driver could set the
sizes.
> >, besides driver default values, user or proprietary
> > algorithm library can manually set the desired image sizes, therefore,
> > we would need the following controls:
> > V4L2_CID_DETECT_SCALE_DOWN_IMG_WIDTH and
> > V4L2_CID_DETECT_SCALE_DOWN_IMG_HEIGHT.
> > In MTK FD driver, we implement these controls as array of
> > V4L2_CTRL_TYPE_U16 with the dimension 15.
>
> Why 15?
>
It consists of one input image size and 14 down-scaled image sizes,
the amount 15 (or say 14) is defined by the MTK FD algo library,
therefore I remain the number of 15 here for communicate with the
library.
Maybe it should be defined as following?
MTK_FD_MAX_SCALE_SIZE_NUM 14
and
MTK_FD_SCALE_ARR_NUM 15
> >
> > For controlling detection speed, we would need the
> > V4L2_CID_DETECT_SPEED, the faster speedup implies the lower accuracy of
> > detection, In MTK FD driver, the max level of speedup is 7, and default
> > value is 0.
> >
> > For MTK FD algorithm user library, they would need select extra
> > detection features(models) used in HW, we need
> > V4L2_CID_MTK_FD_EXTRA_MODEL, this will be set to 1 for using extra
> > model. However, we are considering make this control more
> > chip-independent and can be added into standard.
> > for example, V4L2_CID_DETECTION_FD_MODEL or ...FD_ALGO,
> > drivers can define the detection algorithm or detection model to be used
> > for users to select. How do you think?
>
> Sounds like something that could be a menu control, so it could vary
> between drivers.
>
Ok, and maybe it should be created by v4l2_ctrl_new_int_menu(...)?
> >
> > In short, I summery the control IDs as following:
> > V4L2_CID_DETECT_ANGLE: set the angle of face in degrees. 90 ~ -90
> > degrees.
> > V4L2_CID_DETECT_DIRECTION: set the rotation of the head in degrees.
> > 0~330 degrees.
> > V4L2_CID_DETECT_SCALE_DOWN_IMG_WIDTH: set the image widths for an input
> > image to be scaled down for face detection
> > V4L2_CID_DETECT_SCALE_DOWN_IMG_HEIGHT: set the image heights for an
> > input image to be scaled down for face detection
> > V4L2_CID_DETECT_SPEED: set the detection speed, usually reducing
> > accuracy.
> > V4L2_CID_DETECTION_FD_MODEL: select the detection model or algorithm to
> > be used by face detection driver.
> >
> > > > +#define ENABLE_FD 0x111
> > > > +#define FD_HW_ENABLE 0x4
> > > > +#define FD_INT_EN 0x15c
> > > > +#define FD_INT 0x168
> > > > +#define FD_RESULT 0x178
> > > > +#define FD_IRQ_MASK 0x001
> > > > +
> > > > +#define RS_MAX_BUF_SIZE 2288788
> > > > +#define FD_MAX_SPEEDUP 7
> > > > +#define FD_MAX_POSE_VAL 0xfffffffffffffff
> > > > +#define FD_DEF_POSE_VAL 0x3ff
> > > > +#define MAX_FD_SEL_NUM 1026
> > >
> > > If that file is supposed to be included by anything beyond the driver
> > > itself, we need proper prefixing. (same for anything else in here)
> > >
> > I will fix it as following:
> >
> > #define FD_ENABLE 0x111
> >
> > #define FD_REG_OFFSET_HW_ENABLE 0x4
> > #define FD_REG_OFFSET_INT_EN 0x15c
> > #define FD_REG_OFFSET_INT_VAL 0x168
> > #define FD_REG_OFFSET_RESULT 0x178
> >
> > #define FD_IRQ_MASK 1
> > #define FD_MAX_RS_BUF_SIZE 2288788
> > #define FD_MAX_SPEEDUP 7
> > #define FD_MAX_RESULT_NUM 1026
> >
>
> I'd suggest the MTK_FD_ prefix.
>
Ok, I will use MTK_FD_ prefix.
> > > > diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
> > > > index 3dcfc61..eae876e 100644
> > > > --- a/include/uapi/linux/v4l2-controls.h
> > > > +++ b/include/uapi/linux/v4l2-controls.h
> > > > @@ -192,6 +192,10 @@ enum v4l2_colorfx {
> > > > * We reserve 16 controls for this driver. */
> > > > #define V4L2_CID_USER_IMX_BASE (V4L2_CID_USER_BASE + 0x10b0)
> > > >
> > > > +/* The base for the mediatek FD driver controls */
> > > > +/* We reserve 16 controls for this driver. */
> > > > +#define V4L2_CID_USER_MTK_FD_BASE (V4L2_CID_USER_BASE + 0x10d0)
> > >
> > > Why only the base, but not the actual IDs in uapi ?
> > >
> > I will put actual IDs in uapi/ for user to reference.
> >
> > >
> > > --mtx
> > >
> >
>
> Best regards,
> Tomasz
Best regards,
Jerry
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-07-29 11:58 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-09 8:41 [RFC PATCH V2 0/4] media: platform: Add support for Face Detection (FD) on mt8183 SoC Jerry-ch Chen
2019-07-09 8:41 ` [RFC PATCH V2 1/4] dt-bindings: mt8183: Added FD dt-bindings Jerry-ch Chen
2019-07-12 7:16 ` CK Hu
2019-07-09 8:41 ` [RFC PATCH V2 2/4] dts: arm64: mt8183: Add FD nodes Jerry-ch Chen
2019-07-09 8:41 ` [RFC PATCH V2 3/4] media: platform: Add Mediatek FD driver KConfig Jerry-ch Chen
2019-09-05 12:30 ` Laurent Pinchart
2019-09-05 14:14 ` Jerry-ch Chen
2019-07-09 8:41 ` [RFC PATCH V2 4/4] platform: mtk-isp: Add Mediatek FD driver Jerry-ch Chen
2019-07-09 10:56 ` Enrico Weigelt, metux IT consult
2019-07-29 6:01 ` Jerry-ch Chen
2019-07-29 9:57 ` Tomasz Figa
2019-07-29 11:58 ` Jerry-ch Chen [this message]
2019-08-09 8:07 ` Tomasz Figa
2019-09-05 12:35 ` Laurent Pinchart
2019-08-02 8:28 ` Tomasz Figa
2019-08-25 9:18 ` Jerry-ch Chen
2019-08-26 6:36 ` Tomasz Figa
2019-08-28 2:00 ` Jerry-ch Chen
2019-08-30 8:33 ` Tomasz Figa
2019-09-02 11:47 ` Jerry-ch Chen
2019-09-03 5:19 ` Tomasz Figa
2019-09-03 6:44 ` Jerry-ch Chen
2019-09-03 7:04 ` Tomasz Figa
2019-09-03 11:46 ` Jerry-ch Chen
2019-09-03 12:05 ` Tomasz Figa
2019-09-04 3:38 ` Jerry-ch Chen
2019-09-04 4:15 ` Tomasz Figa
2019-09-04 6:09 ` Jerry-ch Chen
2019-09-04 6:34 ` Tomasz Figa
2019-09-04 8:09 ` Jerry-ch Chen
2019-09-04 8:25 ` Tomasz Figa
2019-09-04 9:01 ` Jerry-ch Chen
2019-09-04 9:03 ` Tomasz Figa
2019-09-04 9:26 ` Jerry-ch Chen
2019-09-04 13:12 ` Tomasz Figa
2019-09-04 13:19 ` Jerry-ch Chen
2019-09-05 7:02 ` Jerry-ch Chen
2019-09-05 7:13 ` Tomasz Figa
2019-09-05 8:16 ` Jerry-ch Chen
2019-09-05 8:52 ` Tomasz Figa
2019-09-05 13:36 ` Jerry-ch Chen
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=1564401491.15267.405.camel@mtksdccf07 \
--to=jerry-ch.chen@mediatek.com \
--cc=Frederic.Chen@mediatek.com \
--cc=Rynn.Wu@mediatek.com \
--cc=Sean.Cheng@mediatek.com \
--cc=christie.yu@mediatek.com \
--cc=devicetree@vger.kernel.org \
--cc=hans.verkuil@cisco.com \
--cc=hverkuil-cisco@xs4all.nl \
--cc=jungo.lin@mediatek.com \
--cc=laurent.pinchart+renesas@ideasonboard.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=lkml@metux.net \
--cc=matthias.bgg@gmail.com \
--cc=mchehab@kernel.org \
--cc=po-yang.huang@mediatek.com \
--cc=sakari.ailus@iki.fi \
--cc=shik@chromium.org \
--cc=sj.huang@mediatek.com \
--cc=srv_heupstream@mediatek.com \
--cc=suleiman@chromium.org \
--cc=tfiga@chromium.org \
--cc=yuzhao@chromium.org \
--cc=zwisler@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;
as well as URLs for NNTP newsgroup(s).