// SPDX-License-Identifier: GPL-2.0
/*
* Broadcom BM2835 V4L2 driver
*
* Copyright © 2013 Raspberry Pi (Trading) Ltd.
*
* Authors: Vincent Sanders @ Collabora
* Dave Stevenson @ Broadcom
* (now dave.stevenson@raspberrypi.org)
* Simon Mellor @ Broadcom
* Luke Diamand @ Broadcom
*/
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <media/videobuf2-vmalloc.h>
#include <media/v4l2-device.h>
#include <media/v4l2-ioctl.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-fh.h>
#include <media/v4l2-event.h>
#include <media/v4l2-common.h>
#include "mmal-common.h"
#include "mmal-vchiq.h"
#include "mmal-parameters.h"
#include "bcm2835-camera.h"
/* The supported V4L2_CID_AUTO_EXPOSURE_BIAS values are from -4.0 to +4.0.
* MMAL values are in 1/6th increments so the MMAL range is -24 to +24.
* V4L2 docs say value "is expressed in terms of EV, drivers should interpret
* the values as 0.001 EV units, where the value 1000 stands for +1 EV."
* V4L2 is limited to a max of 32 values in a menu, so count in 1/3rds from
* -4 to +4
*/
static const s64 ev_bias_qmenu[] = {
-4000, -3667, -3333,
-3000, -2667, -2333,
-2000, -1667, -1333,
-1000, -667, -333,
0, 333, 667,
1000, 1333, 1667,
2000, 2333, 2667,
3000, 3333, 3667,
4000
};
/* Supported ISO values (*1000)
* ISOO = auto ISO
*/
static const s64 iso_qmenu[] = {
0, 100000, 200000, 400000, 800000,
};
static const u32 iso_values[] = {
0, 100, 200, 400, 800,
};
enum bm2835_mmal_ctrl_type {
MMAL_CONTROL_TYPE_STD,
MMAL_CONTROL_TYPE_STD_MENU,
MMAL_CONTROL_TYPE_INT_MENU,
MMAL_CONTROL_TYPE_CLUSTER, /* special cluster entry */
};
struct bm2835_mmal_v4l2_ctrl;
typedef int(bm2835_mmal_v4l2_ctrl_cb)(
struct bm2835_mmal_dev *dev,
struct v4l2_ctrl *ctrl,
const struct bm2835_mmal_v4l2_ctrl *mmal_ctrl);
struct bm2835_mmal_v4l2_ctrl {
u32 id; /* v4l2 control identifier */
enum bm2835_mmal_ctrl_type type;
/* control minimum value or
* mask for MMAL_CONTROL_TYPE_STD_MENU
*/
s32 min;
s32 max; /* maximum value of control */
s32 def; /* default value of control */
s32 step; /* step size of the control */
const s64 *imenu; /* integer menu array */
u32 mmal_id; /*