// 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,
};
static const s64 mains_freq_qmenu[] = {
V4L2_CID_POWER_LINE_FREQUENCY_DISABLED,
V4L2_CID_POWER_LINE_FREQUENCY_50HZ,
V4L2_CID_POWER_LINE_FREQUENCY_60HZ,
V4L2_CID_POWER_LINE_FREQUENCY_AUTO
};
/* Supported video encode modes */
static const s64 bitrate_mode_qmenu[] = {
(s64)V4L2_MPEG_VIDEO_BITRATE_MODE_VBR,
(s64)V4L2_MPEG_VIDEO_BITRATE_MODE_CBR,
};
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 {
<