]>
git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - drivers/staging/media/atomisp/include/media/lm3642.h
2 * include/media/lm3642.h
4 * Copyright (c) 2010-2012 Intel Corporation. All Rights Reserved.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program.
22 #include <linux/videodev2.h>
23 #include <media/v4l2-subdev.h>
25 #define LM3642_NAME "lm3642"
26 #define LM3642_ID 3642
28 #define v4l2_queryctrl_entry_integer(_id, _name,\
29 _minimum, _maximum, _step, \
30 _default_value, _flags) \
33 .type = V4L2_CTRL_TYPE_INTEGER, \
35 .minimum = (_minimum), \
36 .maximum = (_maximum), \
38 .default_value = (_default_value),\
41 #define v4l2_queryctrl_entry_boolean(_id, _name,\
42 _default_value, _flags) \
45 .type = V4L2_CTRL_TYPE_BOOLEAN, \
50 .default_value = (_default_value),\
54 #define s_ctrl_id_entry_integer(_id, _name, \
55 _minimum, _maximum, _step, \
56 _default_value, _flags, \
59 .qc = v4l2_queryctrl_entry_integer(_id, _name,\
60 _minimum, _maximum, _step,\
61 _default_value, _flags), \
66 #define s_ctrl_id_entry_boolean(_id, _name, \
67 _default_value, _flags, \
70 .qc = v4l2_queryctrl_entry_boolean(_id, _name,\
71 _default_value, _flags), \
78 #define LM3642_DEFAULT_TIMEOUT 300U
79 #define LM3642_DEFAULT_RAMP_TIME 0x10 /* 1.024ms */
80 #define LM3642_DEFAULT_INDICATOR_CURRENT 0x01 /* 1.88A */
81 #define LM3642_DEFAULT_FLASH_CURRENT 0x0f /* 1500mA */
83 /* Value settings for Flash Time-out Duration*/
84 #define LM3642_MIN_TIMEOUT 100U
85 #define LM3642_MAX_TIMEOUT 800U
86 #define LM3642_TIMEOUT_STEPSIZE 100U
89 #define LM3642_MODE_SHUTDOWN 0
90 #define LM3642_MODE_INDICATOR 1
91 #define LM3642_MODE_TORCH 2
92 #define LM3642_MODE_FLASH 3
94 /* timer delay time */
95 #define LM3642_TIMER_DELAY 5
97 /* Percentage <-> value macros */
98 #define LM3642_MIN_PERCENT 0U
99 #define LM3642_MAX_PERCENT 100U
100 #define LM3642_CLAMP_PERCENTAGE(val) \
101 clamp(val, LM3642_MIN_PERCENT, LM3642_MAX_PERCENT)
103 #define LM3642_VALUE_TO_PERCENT(v, step) \
104 (((((unsigned long)((v)+1))*(step))+50)/100)
105 #define LM3642_PERCENT_TO_VALUE(p, step) \
106 (((((unsigned long)(p))*100)+((step)>>1))/(step)-1)
108 /* Product specific limits
109 * TODO: get these from platform data */
110 #define LM3642_FLASH_MAX_LVL 0x0F /* 1500mA */
111 #define LM3642_TORCH_MAX_LVL 0x07 /* 187mA */
112 #define LM3642_INDICATOR_MAX_LVL 0x01 /* 1.88A */
114 /* Flash brightness, input is percentage, output is [0..15] */
115 #define LM3642_FLASH_STEP \
116 ((100ul*(LM3642_MAX_PERCENT) \
117 +((LM3642_FLASH_MAX_LVL+1)>>1)) \
118 /((LM3642_FLASH_MAX_LVL+1)))
119 #define LM3642_FLASH_DEFAULT_BRIGHTNESS \
120 LM3642_VALUE_TO_PERCENT(15, LM3642_FLASH_STEP)
122 /* Torch brightness, input is percentage, output is [0..7] */
123 #define LM3642_TORCH_STEP \
124 ((100ul*(LM3642_MAX_PERCENT) \
125 +((LM3642_TORCH_MAX_LVL+1)>>1)) \
126 /((LM3642_TORCH_MAX_LVL+1)))
127 #define LM3642_TORCH_DEFAULT_BRIGHTNESS \
128 LM3642_VALUE_TO_PERCENT(0, LM3642_TORCH_STEP)
130 /* Indicator brightness, input is percentage, output is [0..1] */
131 #define LM3642_INDICATOR_STEP \
132 ((100ul*(LM3642_MAX_PERCENT) \
133 +((LM3642_INDICATOR_MAX_LVL+1)>>1)) \
134 /((LM3642_INDICATOR_MAX_LVL+1)))
135 #define LM3642_INDICATOR_DEFAULT_BRIGHTNESS \
136 LM3642_VALUE_TO_PERCENT(1, LM3642_INDICATOR_STEP)
139 * lm3642_platform_data - Flash controller platform data
141 struct lm3642_platform_data
{
144 int (*power_ctrl
)(struct v4l2_subdev
*subdev
, int on
);
146 unsigned int torch_en
;
147 unsigned int flash_en
;
149 unsigned int ivfm_en
;
152 #endif /* _LM3642_H_ */