Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * V4L2 flash LED sub-device registration helpers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *	Copyright (C) 2015 Samsung Electronics Co., Ltd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *	Author: Jacek Anaszewski <j.anaszewski@samsung.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #ifndef _V4L2_FLASH_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #define _V4L2_FLASH_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <media/v4l2-ctrls.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <media/v4l2-subdev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) struct led_classdev_flash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) struct led_classdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) struct v4l2_flash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) enum led_brightness;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  * struct v4l2_flash_ctrl_data - flash control initialization data, filled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  *				basing on the features declared by the LED flash
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  *				class driver in the v4l2_flash_config
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  * @config:	initialization data for a control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  * @cid:	contains v4l2 flash control id if the config
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  *		field was initialized, 0 otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) struct v4l2_flash_ctrl_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	struct v4l2_ctrl_config config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	u32 cid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  * struct v4l2_flash_ops - V4L2 flash operations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  * @external_strobe_set: Setup strobing the flash by hardware pin state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  *	assertion.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  * @intensity_to_led_brightness: Convert intensity to brightness in a device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  *	specific manner
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  * @led_brightness_to_intensity: convert brightness to intensity in a device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  *	specific manner.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) struct v4l2_flash_ops {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	int (*external_strobe_set)(struct v4l2_flash *v4l2_flash,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 					bool enable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	enum led_brightness (*intensity_to_led_brightness)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 		(struct v4l2_flash *v4l2_flash, s32 intensity);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	s32 (*led_brightness_to_intensity)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 		(struct v4l2_flash *v4l2_flash, enum led_brightness);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53)  * struct v4l2_flash_config - V4L2 Flash sub-device initialization data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)  * @dev_name:			the name of the media entity,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)  *				unique in the system
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)  * @intensity:			non-flash strobe constraints for the LED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57)  * @flash_faults:		bitmask of flash faults that the LED flash class
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)  *				device can report; corresponding LED_FAULT* bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59)  *				definitions are available in the header file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60)  *				<linux/led-class-flash.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61)  * @has_external_strobe:	external strobe capability
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) struct v4l2_flash_config {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	char dev_name[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	struct led_flash_setting intensity;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	u32 flash_faults;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	unsigned int has_external_strobe:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  * struct v4l2_flash - Flash sub-device context
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  * @fled_cdev:		LED flash class device controlled by this sub-device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)  * @iled_cdev:		LED class device representing indicator LED associated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74)  *			with the LED flash class device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75)  * @ops:		V4L2 specific flash ops
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76)  * @sd:			V4L2 sub-device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77)  * @hdl:		flash controls handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78)  * @ctrls:		array of pointers to controls, whose values define
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)  *			the sub-device state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) struct v4l2_flash {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	struct led_classdev_flash *fled_cdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	struct led_classdev *iled_cdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	const struct v4l2_flash_ops *ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	struct v4l2_subdev sd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	struct v4l2_ctrl_handler hdl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	struct v4l2_ctrl **ctrls;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92)  * v4l2_subdev_to_v4l2_flash - Returns a &struct v4l2_flash from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93)  * &struct v4l2_subdev embedded on it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95)  * @sd: pointer to &struct v4l2_subdev
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) static inline struct v4l2_flash *v4l2_subdev_to_v4l2_flash(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 							struct v4l2_subdev *sd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	return container_of(sd, struct v4l2_flash, sd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)  * v4l2_ctrl_to_v4l2_flash - Returns a &struct v4l2_flash from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)  * &struct v4l2_ctrl embedded on it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)  * @c: pointer to &struct v4l2_ctrl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) static inline struct v4l2_flash *v4l2_ctrl_to_v4l2_flash(struct v4l2_ctrl *c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	return container_of(c->handler, struct v4l2_flash, hdl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) #if IS_ENABLED(CONFIG_V4L2_FLASH_LED_CLASS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)  * v4l2_flash_init - initialize V4L2 flash led sub-device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)  * @dev:	flash device, e.g. an I2C device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)  * @fwn:	fwnode_handle of the LED, may be NULL if the same as device's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)  * @fled_cdev:	LED flash class device to wrap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)  * @ops:	V4L2 Flash device ops
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)  * @config:	initialization data for V4L2 Flash sub-device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)  * Create V4L2 Flash sub-device wrapping given LED subsystem device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)  * The ops pointer is stored by the V4L2 flash framework. No
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)  * references are held to config nor its contents once this function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)  * has returned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)  * Returns: A valid pointer, or, when an error occurs, the return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)  * value is encoded using ERR_PTR(). Use IS_ERR() to check and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)  * PTR_ERR() to obtain the numeric return value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) struct v4l2_flash *v4l2_flash_init(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	struct device *dev, struct fwnode_handle *fwn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	struct led_classdev_flash *fled_cdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	const struct v4l2_flash_ops *ops, struct v4l2_flash_config *config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)  * v4l2_flash_indicator_init - initialize V4L2 indicator sub-device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)  * @dev:	flash device, e.g. an I2C device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)  * @fwn:	fwnode_handle of the LED, may be NULL if the same as device's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)  * @iled_cdev:	LED flash class device representing the indicator LED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)  * @config:	initialization data for V4L2 Flash sub-device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)  * Create V4L2 Flash sub-device wrapping given LED subsystem device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)  * The ops pointer is stored by the V4L2 flash framework. No
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)  * references are held to config nor its contents once this function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)  * has returned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)  * Returns: A valid pointer, or, when an error occurs, the return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)  * value is encoded using ERR_PTR(). Use IS_ERR() to check and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)  * PTR_ERR() to obtain the numeric return value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) struct v4l2_flash *v4l2_flash_indicator_init(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	struct device *dev, struct fwnode_handle *fwn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	struct led_classdev *iled_cdev, struct v4l2_flash_config *config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)  * v4l2_flash_release - release V4L2 Flash sub-device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)  * @v4l2_flash: the V4L2 Flash sub-device to release
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)  * Release V4L2 Flash sub-device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) void v4l2_flash_release(struct v4l2_flash *v4l2_flash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) static inline struct v4l2_flash *v4l2_flash_init(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	struct device *dev, struct fwnode_handle *fwn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	struct led_classdev_flash *fled_cdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	const struct v4l2_flash_ops *ops, struct v4l2_flash_config *config)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) static inline struct v4l2_flash *v4l2_flash_indicator_init(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	struct device *dev, struct fwnode_handle *fwn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	struct led_classdev *iled_cdev, struct v4l2_flash_config *config)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) static inline void v4l2_flash_release(struct v4l2_flash *v4l2_flash)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) #endif /* CONFIG_V4L2_FLASH_LED_CLASS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) #endif /* _V4L2_FLASH_H */