aboutsummaryrefslogtreecommitdiffstats
path: root/include/media
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-04-04 12:50:07 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-04-04 12:50:07 -0400
commit3c83e61e67256e0bb08c46cc2db43b58fd617251 (patch)
tree0233e1e04e6449c60b01ff5dea8bea85bcf22f08 /include/media
parent4a4389abdd9822fdf3cc2ac6ed87eb811fd43acc (diff)
parenta83b93a7480441a47856dc9104bea970e84cda87 (diff)
Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
Pull media updates from Mauro Carvalho Chehab: "The main set of series of patches for media subsystem, including: - document RC sysfs class - added an API to setup scancode to allow waking up systems using the Remote Controller - add API for SDR devices. Drivers are still on staging - some API improvements for getting EDID data from media inputs/outputs - new DVB frontend driver for drx-j (ATSC) - one driver (it913x/it9137) got removed, in favor of an improvement on another driver (af9035) - added a skeleton V4L2 PCI driver at documentation - added a dual flash driver (lm3646) - added a new IR driver (img-ir) - added an IR scancode decoder for the Sharp protocol - some improvements at the usbtv driver, to allow its core to be reused. - added a new SDR driver (rtl2832u_sdr) - added a new tuner driver (msi001) - several improvements at em28xx driver to fix PM support, device removal and to split the V4L2 specific bits into a separate sub-driver - one driver got converted to videobuf2 (s2255drv) - the e4000 tuner driver now follows an improved binding model - some fixes at V4L2 compat32 code - several fixes and enhancements at videobuf2 code - some cleanups at V4L2 API documentation - usual driver enhancements, new board additions and misc fixups" [ NOTE! This merge effective drops commit 4329b93b283c ("of: Reduce indentation in of_graph_get_next_endpoint"). The of_graph_get_next_endpoint() function was moved and renamed by commit fd9fdb78a9bf ("[media] of: move graph helpers from drivers/media/v4l2-core to drivers/of"). It was originally called v4l2_of_get_next_endpoint() and lived in the file drivers/media/v4l2-core/v4l2-of.c. In that original location, it was then fixed to support empty port nodes by commit b9db140c1e46 ("[media] v4l: of: Support empty port nodes"), and that commit clashes badly with the dropped "Reduce intendation" commit. I had to choose one or the other, and decided that the "Support empty port nodes" commit was more important ] * 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (426 commits) [media] em28xx-dvb: fix PCTV 461e tuner I2C binding Revert "[media] em28xx-dvb: fix PCTV 461e tuner I2C binding" [media] em28xx: fix PCTV 290e LNA oops [media] em28xx-dvb: fix PCTV 461e tuner I2C binding [media] m88ds3103: fix bug on .set_tone() [media] saa7134: fix WARN_ON during resume [media] v4l2-dv-timings: add module name, description, license [media] videodev2.h: add parenthesis around macro arguments [media] saa6752hs: depends on CRC32 [media] si4713: fix Kconfig dependencies [media] Sensoray 2255 uses videobuf2 [media] adv7180: free an interrupt on failure paths in init_device() [media] e4000: make VIDEO_V4L2 dependency optional [media] af9033: Don't export functions for the hardware filter [media] af9035: use af9033 PID filters [media] af9033: implement PID filter [media] rtl2832_sdr: do not use dynamic stack allocation [media] e4000: fix 32-bit build error [media] em28xx-audio: make sure audio is unmuted on open() [media] DocBook media: v4l2_format_sdr was renamed to v4l2_sdr_format ...
Diffstat (limited to 'include/media')
-rw-r--r--include/media/adv7842.h3
-rw-r--r--include/media/lm3646.h87
-rw-r--r--include/media/rc-core.h80
-rw-r--r--include/media/rc-map.h6
-rw-r--r--include/media/v4l2-dev.h3
-rw-r--r--include/media/v4l2-ioctl.h10
-rw-r--r--include/media/v4l2-subdev.h9
-rw-r--r--include/media/videobuf2-core.h117
8 files changed, 276 insertions, 39 deletions
diff --git a/include/media/adv7842.h b/include/media/adv7842.h
index 39322091e8b0..924cbb8d004a 100644
--- a/include/media/adv7842.h
+++ b/include/media/adv7842.h
@@ -220,6 +220,9 @@ struct adv7842_platform_data {
220 unsigned sdp_free_run_cbar_en:1; 220 unsigned sdp_free_run_cbar_en:1;
221 unsigned sdp_free_run_force:1; 221 unsigned sdp_free_run_force:1;
222 222
223 /* HPA manual (0) or auto (1), affects HDMI register 0x69 */
224 unsigned hpa_auto:1;
225
223 struct adv7842_sdp_csc_coeff sdp_csc_coeff; 226 struct adv7842_sdp_csc_coeff sdp_csc_coeff;
224 227
225 struct adv7842_sdp_io_sync_adjustment sdp_io_sync_625; 228 struct adv7842_sdp_io_sync_adjustment sdp_io_sync_625;
diff --git a/include/media/lm3646.h b/include/media/lm3646.h
new file mode 100644
index 000000000000..c6acf5a1d640
--- /dev/null
+++ b/include/media/lm3646.h
@@ -0,0 +1,87 @@
1/*
2 * include/media/lm3646.h
3 *
4 * Copyright (C) 2014 Texas Instruments
5 *
6 * Contact: Daniel Jeong <gshark.jeong@gmail.com>
7 * Ldd-Mlp <ldd-mlp@list.ti.com>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * version 2 as published by the Free Software Foundation.
12 */
13
14#ifndef __LM3646_H__
15#define __LM3646_H__
16
17#include <media/v4l2-subdev.h>
18
19#define LM3646_NAME "lm3646"
20#define LM3646_I2C_ADDR_REV1 (0x67)
21#define LM3646_I2C_ADDR_REV0 (0x63)
22
23/* TOTAL FLASH Brightness Max
24 * min 93350uA, step 93750uA, max 1499600uA
25 */
26#define LM3646_TOTAL_FLASH_BRT_MIN 93350
27#define LM3646_TOTAL_FLASH_BRT_STEP 93750
28#define LM3646_TOTAL_FLASH_BRT_MAX 1499600
29#define LM3646_TOTAL_FLASH_BRT_uA_TO_REG(a) \
30 ((a) < LM3646_TOTAL_FLASH_BRT_MIN ? 0 : \
31 ((((a) - LM3646_TOTAL_FLASH_BRT_MIN) / LM3646_TOTAL_FLASH_BRT_STEP)))
32
33/* TOTAL TORCH Brightness Max
34 * min 23040uA, step 23430uA, max 187100uA
35 */
36#define LM3646_TOTAL_TORCH_BRT_MIN 23040
37#define LM3646_TOTAL_TORCH_BRT_STEP 23430
38#define LM3646_TOTAL_TORCH_BRT_MAX 187100
39#define LM3646_TOTAL_TORCH_BRT_uA_TO_REG(a) \
40 ((a) < LM3646_TOTAL_TORCH_BRT_MIN ? 0 : \
41 ((((a) - LM3646_TOTAL_TORCH_BRT_MIN) / LM3646_TOTAL_TORCH_BRT_STEP)))
42
43/* LED1 FLASH Brightness
44 * min 23040uA, step 11718uA, max 1499600uA
45 */
46#define LM3646_LED1_FLASH_BRT_MIN 23040
47#define LM3646_LED1_FLASH_BRT_STEP 11718
48#define LM3646_LED1_FLASH_BRT_MAX 1499600
49#define LM3646_LED1_FLASH_BRT_uA_TO_REG(a) \
50 ((a) <= LM3646_LED1_FLASH_BRT_MIN ? 0 : \
51 ((((a) - LM3646_LED1_FLASH_BRT_MIN) / LM3646_LED1_FLASH_BRT_STEP))+1)
52
53/* LED1 TORCH Brightness
54 * min 2530uA, step 1460uA, max 187100uA
55 */
56#define LM3646_LED1_TORCH_BRT_MIN 2530
57#define LM3646_LED1_TORCH_BRT_STEP 1460
58#define LM3646_LED1_TORCH_BRT_MAX 187100
59#define LM3646_LED1_TORCH_BRT_uA_TO_REG(a) \
60 ((a) <= LM3646_LED1_TORCH_BRT_MIN ? 0 : \
61 ((((a) - LM3646_LED1_TORCH_BRT_MIN) / LM3646_LED1_TORCH_BRT_STEP))+1)
62
63/* FLASH TIMEOUT DURATION
64 * min 50ms, step 50ms, max 400ms
65 */
66#define LM3646_FLASH_TOUT_MIN 50
67#define LM3646_FLASH_TOUT_STEP 50
68#define LM3646_FLASH_TOUT_MAX 400
69#define LM3646_FLASH_TOUT_ms_TO_REG(a) \
70 ((a) <= LM3646_FLASH_TOUT_MIN ? 0 : \
71 (((a) - LM3646_FLASH_TOUT_MIN) / LM3646_FLASH_TOUT_STEP))
72
73/* struct lm3646_platform_data
74 *
75 * @flash_timeout: flash timeout
76 * @led1_flash_brt: led1 flash mode brightness, uA
77 * @led1_torch_brt: led1 torch mode brightness, uA
78 */
79struct lm3646_platform_data {
80
81 u32 flash_timeout;
82
83 u32 led1_flash_brt;
84 u32 led1_torch_brt;
85};
86
87#endif /* __LM3646_H__ */
diff --git a/include/media/rc-core.h b/include/media/rc-core.h
index 2f6f1f78d958..0b9f890ce431 100644
--- a/include/media/rc-core.h
+++ b/include/media/rc-core.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Remote Controller core header 2 * Remote Controller core header
3 * 3 *
4 * Copyright (C) 2009-2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 4 * Copyright (C) 2009-2010 by Mauro Carvalho Chehab
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
@@ -35,6 +35,29 @@ enum rc_driver_type {
35}; 35};
36 36
37/** 37/**
38 * struct rc_scancode_filter - Filter scan codes.
39 * @data: Scancode data to match.
40 * @mask: Mask of bits of scancode to compare.
41 */
42struct rc_scancode_filter {
43 u32 data;
44 u32 mask;
45};
46
47/**
48 * enum rc_filter_type - Filter type constants.
49 * @RC_FILTER_NORMAL: Filter for normal operation.
50 * @RC_FILTER_WAKEUP: Filter for waking from suspend.
51 * @RC_FILTER_MAX: Number of filter types.
52 */
53enum rc_filter_type {
54 RC_FILTER_NORMAL = 0,
55 RC_FILTER_WAKEUP,
56
57 RC_FILTER_MAX
58};
59
60/**
38 * struct rc_dev - represents a remote control device 61 * struct rc_dev - represents a remote control device
39 * @dev: driver model's view of this device 62 * @dev: driver model's view of this device
40 * @input_name: name of the input child device 63 * @input_name: name of the input child device
@@ -50,8 +73,10 @@ enum rc_driver_type {
50 * @input_dev: the input child device used to communicate events to userspace 73 * @input_dev: the input child device used to communicate events to userspace
51 * @driver_type: specifies if protocol decoding is done in hardware or software 74 * @driver_type: specifies if protocol decoding is done in hardware or software
52 * @idle: used to keep track of RX state 75 * @idle: used to keep track of RX state
53 * @allowed_protos: bitmask with the supported RC_BIT_* protocols 76 * @allowed_protocols: bitmask with the supported RC_BIT_* protocols for each
54 * @enabled_protocols: bitmask with the enabled RC_BIT_* protocols 77 * filter type
78 * @enabled_protocols: bitmask with the enabled RC_BIT_* protocols for each
79 * filter type
55 * @scanmask: some hardware decoders are not capable of providing the full 80 * @scanmask: some hardware decoders are not capable of providing the full
56 * scancode to the application. As this is a hardware limit, we can't do 81 * scancode to the application. As this is a hardware limit, we can't do
57 * anything with it. Yet, as the same keycode table can be used with other 82 * anything with it. Yet, as the same keycode table can be used with other
@@ -70,7 +95,10 @@ enum rc_driver_type {
70 * @max_timeout: maximum timeout supported by device 95 * @max_timeout: maximum timeout supported by device
71 * @rx_resolution : resolution (in ns) of input sampler 96 * @rx_resolution : resolution (in ns) of input sampler
72 * @tx_resolution: resolution (in ns) of output sampler 97 * @tx_resolution: resolution (in ns) of output sampler
98 * @scancode_filters: scancode filters (indexed by enum rc_filter_type)
73 * @change_protocol: allow changing the protocol used on hardware decoders 99 * @change_protocol: allow changing the protocol used on hardware decoders
100 * @change_wakeup_protocol: allow changing the protocol used for wakeup
101 * filtering
74 * @open: callback to allow drivers to enable polling/irq when IR input device 102 * @open: callback to allow drivers to enable polling/irq when IR input device
75 * is opened. 103 * is opened.
76 * @close: callback to allow drivers to disable polling/irq when IR input device 104 * @close: callback to allow drivers to disable polling/irq when IR input device
@@ -84,6 +112,7 @@ enum rc_driver_type {
84 * device doesn't interrupt host until it sees IR pulses 112 * device doesn't interrupt host until it sees IR pulses
85 * @s_learning_mode: enable wide band receiver used for learning 113 * @s_learning_mode: enable wide band receiver used for learning
86 * @s_carrier_report: enable carrier reports 114 * @s_carrier_report: enable carrier reports
115 * @s_filter: set the scancode filter of a given type
87 */ 116 */
88struct rc_dev { 117struct rc_dev {
89 struct device dev; 118 struct device dev;
@@ -99,8 +128,8 @@ struct rc_dev {
99 struct input_dev *input_dev; 128 struct input_dev *input_dev;
100 enum rc_driver_type driver_type; 129 enum rc_driver_type driver_type;
101 bool idle; 130 bool idle;
102 u64 allowed_protos; 131 u64 allowed_protocols[RC_FILTER_MAX];
103 u64 enabled_protocols; 132 u64 enabled_protocols[RC_FILTER_MAX];
104 u32 users; 133 u32 users;
105 u32 scanmask; 134 u32 scanmask;
106 void *priv; 135 void *priv;
@@ -116,7 +145,9 @@ struct rc_dev {
116 u32 max_timeout; 145 u32 max_timeout;
117 u32 rx_resolution; 146 u32 rx_resolution;
118 u32 tx_resolution; 147 u32 tx_resolution;
148 struct rc_scancode_filter scancode_filters[RC_FILTER_MAX];
119 int (*change_protocol)(struct rc_dev *dev, u64 *rc_type); 149 int (*change_protocol)(struct rc_dev *dev, u64 *rc_type);
150 int (*change_wakeup_protocol)(struct rc_dev *dev, u64 *rc_type);
120 int (*open)(struct rc_dev *dev); 151 int (*open)(struct rc_dev *dev);
121 void (*close)(struct rc_dev *dev); 152 void (*close)(struct rc_dev *dev);
122 int (*s_tx_mask)(struct rc_dev *dev, u32 mask); 153 int (*s_tx_mask)(struct rc_dev *dev, u32 mask);
@@ -127,10 +158,49 @@ struct rc_dev {
127 void (*s_idle)(struct rc_dev *dev, bool enable); 158 void (*s_idle)(struct rc_dev *dev, bool enable);
128 int (*s_learning_mode)(struct rc_dev *dev, int enable); 159 int (*s_learning_mode)(struct rc_dev *dev, int enable);
129 int (*s_carrier_report) (struct rc_dev *dev, int enable); 160 int (*s_carrier_report) (struct rc_dev *dev, int enable);
161 int (*s_filter)(struct rc_dev *dev,
162 enum rc_filter_type type,
163 struct rc_scancode_filter *filter);
130}; 164};
131 165
132#define to_rc_dev(d) container_of(d, struct rc_dev, dev) 166#define to_rc_dev(d) container_of(d, struct rc_dev, dev)
133 167
168static inline bool rc_protocols_allowed(struct rc_dev *rdev, u64 protos)
169{
170 return rdev->allowed_protocols[RC_FILTER_NORMAL] & protos;
171}
172
173/* should be called prior to registration or with mutex held */
174static inline void rc_set_allowed_protocols(struct rc_dev *rdev, u64 protos)
175{
176 rdev->allowed_protocols[RC_FILTER_NORMAL] = protos;
177}
178
179static inline bool rc_protocols_enabled(struct rc_dev *rdev, u64 protos)
180{
181 return rdev->enabled_protocols[RC_FILTER_NORMAL] & protos;
182}
183
184/* should be called prior to registration or with mutex held */
185static inline void rc_set_enabled_protocols(struct rc_dev *rdev, u64 protos)
186{
187 rdev->enabled_protocols[RC_FILTER_NORMAL] = protos;
188}
189
190/* should be called prior to registration or with mutex held */
191static inline void rc_set_allowed_wakeup_protocols(struct rc_dev *rdev,
192 u64 protos)
193{
194 rdev->allowed_protocols[RC_FILTER_WAKEUP] = protos;
195}
196
197/* should be called prior to registration or with mutex held */
198static inline void rc_set_enabled_wakeup_protocols(struct rc_dev *rdev,
199 u64 protos)
200{
201 rdev->enabled_protocols[RC_FILTER_WAKEUP] = protos;
202}
203
134/* 204/*
135 * From rc-main.c 205 * From rc-main.c
136 * Those functions can be used on any type of Remote Controller. They 206 * Those functions can be used on any type of Remote Controller. They
diff --git a/include/media/rc-map.h b/include/media/rc-map.h
index a20ed97d7d8a..e5aa2409c0ea 100644
--- a/include/media/rc-map.h
+++ b/include/media/rc-map.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * rc-map.h - define RC map names used by RC drivers 2 * rc-map.h - define RC map names used by RC drivers
3 * 3 *
4 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 4 * Copyright (c) 2010 by Mauro Carvalho Chehab
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
@@ -30,6 +30,7 @@ enum rc_type {
30 RC_TYPE_RC6_6A_24 = 15, /* Philips RC6-6A-24 protocol */ 30 RC_TYPE_RC6_6A_24 = 15, /* Philips RC6-6A-24 protocol */
31 RC_TYPE_RC6_6A_32 = 16, /* Philips RC6-6A-32 protocol */ 31 RC_TYPE_RC6_6A_32 = 16, /* Philips RC6-6A-32 protocol */
32 RC_TYPE_RC6_MCE = 17, /* MCE (Philips RC6-6A-32 subtype) protocol */ 32 RC_TYPE_RC6_MCE = 17, /* MCE (Philips RC6-6A-32 subtype) protocol */
33 RC_TYPE_SHARP = 18, /* Sharp protocol */
33}; 34};
34 35
35#define RC_BIT_NONE 0 36#define RC_BIT_NONE 0
@@ -51,6 +52,7 @@ enum rc_type {
51#define RC_BIT_RC6_6A_24 (1 << RC_TYPE_RC6_6A_24) 52#define RC_BIT_RC6_6A_24 (1 << RC_TYPE_RC6_6A_24)
52#define RC_BIT_RC6_6A_32 (1 << RC_TYPE_RC6_6A_32) 53#define RC_BIT_RC6_6A_32 (1 << RC_TYPE_RC6_6A_32)
53#define RC_BIT_RC6_MCE (1 << RC_TYPE_RC6_MCE) 54#define RC_BIT_RC6_MCE (1 << RC_TYPE_RC6_MCE)
55#define RC_BIT_SHARP (1 << RC_TYPE_SHARP)
54 56
55#define RC_BIT_ALL (RC_BIT_UNKNOWN | RC_BIT_OTHER | RC_BIT_LIRC | \ 57#define RC_BIT_ALL (RC_BIT_UNKNOWN | RC_BIT_OTHER | RC_BIT_LIRC | \
56 RC_BIT_RC5 | RC_BIT_RC5X | RC_BIT_RC5_SZ | \ 58 RC_BIT_RC5 | RC_BIT_RC5X | RC_BIT_RC5_SZ | \
@@ -58,7 +60,7 @@ enum rc_type {
58 RC_BIT_SONY12 | RC_BIT_SONY15 | RC_BIT_SONY20 | \ 60 RC_BIT_SONY12 | RC_BIT_SONY15 | RC_BIT_SONY20 | \
59 RC_BIT_NEC | RC_BIT_SANYO | RC_BIT_MCE_KBD | \ 61 RC_BIT_NEC | RC_BIT_SANYO | RC_BIT_MCE_KBD | \
60 RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 | RC_BIT_RC6_6A_24 | \ 62 RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 | RC_BIT_RC6_6A_24 | \
61 RC_BIT_RC6_6A_32 | RC_BIT_RC6_MCE) 63 RC_BIT_RC6_6A_32 | RC_BIT_RC6_MCE | RC_BIT_SHARP)
62 64
63struct rc_map_table { 65struct rc_map_table {
64 u32 scancode; 66 u32 scancode;
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
index c768c9f8abc2..eec6e460f649 100644
--- a/include/media/v4l2-dev.h
+++ b/include/media/v4l2-dev.h
@@ -24,7 +24,8 @@
24#define VFL_TYPE_VBI 1 24#define VFL_TYPE_VBI 1
25#define VFL_TYPE_RADIO 2 25#define VFL_TYPE_RADIO 2
26#define VFL_TYPE_SUBDEV 3 26#define VFL_TYPE_SUBDEV 3
27#define VFL_TYPE_MAX 4 27#define VFL_TYPE_SDR 4
28#define VFL_TYPE_MAX 5
28 29
29/* Is this a receiver, transmitter or mem-to-mem? */ 30/* Is this a receiver, transmitter or mem-to-mem? */
30/* Ignored for VFL_TYPE_SUBDEV. */ 31/* Ignored for VFL_TYPE_SUBDEV. */
diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
index e0b74a430b3a..50cf7c110a70 100644
--- a/include/media/v4l2-ioctl.h
+++ b/include/media/v4l2-ioctl.h
@@ -40,6 +40,8 @@ struct v4l2_ioctl_ops {
40 struct v4l2_fmtdesc *f); 40 struct v4l2_fmtdesc *f);
41 int (*vidioc_enum_fmt_vid_out_mplane)(struct file *file, void *fh, 41 int (*vidioc_enum_fmt_vid_out_mplane)(struct file *file, void *fh,
42 struct v4l2_fmtdesc *f); 42 struct v4l2_fmtdesc *f);
43 int (*vidioc_enum_fmt_sdr_cap) (struct file *file, void *fh,
44 struct v4l2_fmtdesc *f);
43 45
44 /* VIDIOC_G_FMT handlers */ 46 /* VIDIOC_G_FMT handlers */
45 int (*vidioc_g_fmt_vid_cap) (struct file *file, void *fh, 47 int (*vidioc_g_fmt_vid_cap) (struct file *file, void *fh,
@@ -62,6 +64,8 @@ struct v4l2_ioctl_ops {
62 struct v4l2_format *f); 64 struct v4l2_format *f);
63 int (*vidioc_g_fmt_vid_out_mplane)(struct file *file, void *fh, 65 int (*vidioc_g_fmt_vid_out_mplane)(struct file *file, void *fh,
64 struct v4l2_format *f); 66 struct v4l2_format *f);
67 int (*vidioc_g_fmt_sdr_cap) (struct file *file, void *fh,
68 struct v4l2_format *f);
65 69
66 /* VIDIOC_S_FMT handlers */ 70 /* VIDIOC_S_FMT handlers */
67 int (*vidioc_s_fmt_vid_cap) (struct file *file, void *fh, 71 int (*vidioc_s_fmt_vid_cap) (struct file *file, void *fh,
@@ -84,6 +88,8 @@ struct v4l2_ioctl_ops {
84 struct v4l2_format *f); 88 struct v4l2_format *f);
85 int (*vidioc_s_fmt_vid_out_mplane)(struct file *file, void *fh, 89 int (*vidioc_s_fmt_vid_out_mplane)(struct file *file, void *fh,
86 struct v4l2_format *f); 90 struct v4l2_format *f);
91 int (*vidioc_s_fmt_sdr_cap) (struct file *file, void *fh,
92 struct v4l2_format *f);
87 93
88 /* VIDIOC_TRY_FMT handlers */ 94 /* VIDIOC_TRY_FMT handlers */
89 int (*vidioc_try_fmt_vid_cap) (struct file *file, void *fh, 95 int (*vidioc_try_fmt_vid_cap) (struct file *file, void *fh,
@@ -106,6 +112,8 @@ struct v4l2_ioctl_ops {
106 struct v4l2_format *f); 112 struct v4l2_format *f);
107 int (*vidioc_try_fmt_vid_out_mplane)(struct file *file, void *fh, 113 int (*vidioc_try_fmt_vid_out_mplane)(struct file *file, void *fh,
108 struct v4l2_format *f); 114 struct v4l2_format *f);
115 int (*vidioc_try_fmt_sdr_cap) (struct file *file, void *fh,
116 struct v4l2_format *f);
109 117
110 /* Buffer handlers */ 118 /* Buffer handlers */
111 int (*vidioc_reqbufs) (struct file *file, void *fh, struct v4l2_requestbuffers *b); 119 int (*vidioc_reqbufs) (struct file *file, void *fh, struct v4l2_requestbuffers *b);
@@ -265,6 +273,8 @@ struct v4l2_ioctl_ops {
265 struct v4l2_enum_dv_timings *timings); 273 struct v4l2_enum_dv_timings *timings);
266 int (*vidioc_dv_timings_cap) (struct file *file, void *fh, 274 int (*vidioc_dv_timings_cap) (struct file *file, void *fh,
267 struct v4l2_dv_timings_cap *cap); 275 struct v4l2_dv_timings_cap *cap);
276 int (*vidioc_g_edid) (struct file *file, void *fh, struct v4l2_edid *edid);
277 int (*vidioc_s_edid) (struct file *file, void *fh, struct v4l2_edid *edid);
268 278
269 int (*vidioc_subscribe_event) (struct v4l2_fh *fh, 279 int (*vidioc_subscribe_event) (struct v4l2_fh *fh,
270 const struct v4l2_event_subscription *sub); 280 const struct v4l2_event_subscription *sub);
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index d67210a37ef3..28f4d8c3cf7d 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -162,6 +162,10 @@ struct v4l2_subdev_core_ops {
162 int (*g_std)(struct v4l2_subdev *sd, v4l2_std_id *norm); 162 int (*g_std)(struct v4l2_subdev *sd, v4l2_std_id *norm);
163 int (*s_std)(struct v4l2_subdev *sd, v4l2_std_id norm); 163 int (*s_std)(struct v4l2_subdev *sd, v4l2_std_id norm);
164 long (*ioctl)(struct v4l2_subdev *sd, unsigned int cmd, void *arg); 164 long (*ioctl)(struct v4l2_subdev *sd, unsigned int cmd, void *arg);
165#ifdef CONFIG_COMPAT
166 long (*compat_ioctl32)(struct v4l2_subdev *sd, unsigned int cmd,
167 unsigned long arg);
168#endif
165#ifdef CONFIG_VIDEO_ADV_DEBUG 169#ifdef CONFIG_VIDEO_ADV_DEBUG
166 int (*g_register)(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg); 170 int (*g_register)(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg);
167 int (*s_register)(struct v4l2_subdev *sd, const struct v4l2_dbg_register *reg); 171 int (*s_register)(struct v4l2_subdev *sd, const struct v4l2_dbg_register *reg);
@@ -192,6 +196,7 @@ struct v4l2_subdev_tuner_ops {
192 int (*s_radio)(struct v4l2_subdev *sd); 196 int (*s_radio)(struct v4l2_subdev *sd);
193 int (*s_frequency)(struct v4l2_subdev *sd, const struct v4l2_frequency *freq); 197 int (*s_frequency)(struct v4l2_subdev *sd, const struct v4l2_frequency *freq);
194 int (*g_frequency)(struct v4l2_subdev *sd, struct v4l2_frequency *freq); 198 int (*g_frequency)(struct v4l2_subdev *sd, struct v4l2_frequency *freq);
199 int (*enum_freq_bands)(struct v4l2_subdev *sd, struct v4l2_frequency_band *band);
195 int (*g_tuner)(struct v4l2_subdev *sd, struct v4l2_tuner *vt); 200 int (*g_tuner)(struct v4l2_subdev *sd, struct v4l2_tuner *vt);
196 int (*s_tuner)(struct v4l2_subdev *sd, const struct v4l2_tuner *vt); 201 int (*s_tuner)(struct v4l2_subdev *sd, const struct v4l2_tuner *vt);
197 int (*g_modulator)(struct v4l2_subdev *sd, struct v4l2_modulator *vm); 202 int (*g_modulator)(struct v4l2_subdev *sd, struct v4l2_modulator *vm);
@@ -503,8 +508,8 @@ struct v4l2_subdev_pad_ops {
503 struct v4l2_subdev_selection *sel); 508 struct v4l2_subdev_selection *sel);
504 int (*set_selection)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 509 int (*set_selection)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
505 struct v4l2_subdev_selection *sel); 510 struct v4l2_subdev_selection *sel);
506 int (*get_edid)(struct v4l2_subdev *sd, struct v4l2_subdev_edid *edid); 511 int (*get_edid)(struct v4l2_subdev *sd, struct v4l2_edid *edid);
507 int (*set_edid)(struct v4l2_subdev *sd, struct v4l2_subdev_edid *edid); 512 int (*set_edid)(struct v4l2_subdev *sd, struct v4l2_edid *edid);
508#ifdef CONFIG_MEDIA_CONTROLLER 513#ifdef CONFIG_MEDIA_CONTROLLER
509 int (*link_validate)(struct v4l2_subdev *sd, struct media_link *link, 514 int (*link_validate)(struct v4l2_subdev *sd, struct media_link *link,
510 struct v4l2_subdev_format *source_fmt, 515 struct v4l2_subdev_format *source_fmt,
diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
index bef53ce555d2..af4621109726 100644
--- a/include/media/videobuf2-core.h
+++ b/include/media/videobuf2-core.h
@@ -34,49 +34,49 @@ struct vb2_fileio_data;
34 * usually will result in the allocator freeing the buffer (if 34 * usually will result in the allocator freeing the buffer (if
35 * no other users of this buffer are present); the buf_priv 35 * no other users of this buffer are present); the buf_priv
36 * argument is the allocator private per-buffer structure 36 * argument is the allocator private per-buffer structure
37 * previously returned from the alloc callback 37 * previously returned from the alloc callback.
38 * @get_userptr: acquire userspace memory for a hardware operation; used for 38 * @get_userptr: acquire userspace memory for a hardware operation; used for
39 * USERPTR memory types; vaddr is the address passed to the 39 * USERPTR memory types; vaddr is the address passed to the
40 * videobuf layer when queuing a video buffer of USERPTR type; 40 * videobuf layer when queuing a video buffer of USERPTR type;
41 * should return an allocator private per-buffer structure 41 * should return an allocator private per-buffer structure
42 * associated with the buffer on success, NULL on failure; 42 * associated with the buffer on success, NULL on failure;
43 * the returned private structure will then be passed as buf_priv 43 * the returned private structure will then be passed as buf_priv
44 * argument to other ops in this structure 44 * argument to other ops in this structure.
45 * @put_userptr: inform the allocator that a USERPTR buffer will no longer 45 * @put_userptr: inform the allocator that a USERPTR buffer will no longer
46 * be used 46 * be used.
47 * @attach_dmabuf: attach a shared struct dma_buf for a hardware operation; 47 * @attach_dmabuf: attach a shared struct dma_buf for a hardware operation;
48 * used for DMABUF memory types; alloc_ctx is the alloc context 48 * used for DMABUF memory types; alloc_ctx is the alloc context
49 * dbuf is the shared dma_buf; returns NULL on failure; 49 * dbuf is the shared dma_buf; returns NULL on failure;
50 * allocator private per-buffer structure on success; 50 * allocator private per-buffer structure on success;
51 * this needs to be used for further accesses to the buffer 51 * this needs to be used for further accesses to the buffer.
52 * @detach_dmabuf: inform the exporter of the buffer that the current DMABUF 52 * @detach_dmabuf: inform the exporter of the buffer that the current DMABUF
53 * buffer is no longer used; the buf_priv argument is the 53 * buffer is no longer used; the buf_priv argument is the
54 * allocator private per-buffer structure previously returned 54 * allocator private per-buffer structure previously returned
55 * from the attach_dmabuf callback 55 * from the attach_dmabuf callback.
56 * @map_dmabuf: request for access to the dmabuf from allocator; the allocator 56 * @map_dmabuf: request for access to the dmabuf from allocator; the allocator
57 * of dmabuf is informed that this driver is going to use the 57 * of dmabuf is informed that this driver is going to use the
58 * dmabuf 58 * dmabuf.
59 * @unmap_dmabuf: releases access control to the dmabuf - allocator is notified 59 * @unmap_dmabuf: releases access control to the dmabuf - allocator is notified
60 * that this driver is done using the dmabuf for now 60 * that this driver is done using the dmabuf for now.
61 * @prepare: called every time the buffer is passed from userspace to the 61 * @prepare: called every time the buffer is passed from userspace to the
62 * driver, useful for cache synchronisation, optional 62 * driver, useful for cache synchronisation, optional.
63 * @finish: called every time the buffer is passed back from the driver 63 * @finish: called every time the buffer is passed back from the driver
64 * to the userspace, also optional 64 * to the userspace, also optional.
65 * @vaddr: return a kernel virtual address to a given memory buffer 65 * @vaddr: return a kernel virtual address to a given memory buffer
66 * associated with the passed private structure or NULL if no 66 * associated with the passed private structure or NULL if no
67 * such mapping exists 67 * such mapping exists.
68 * @cookie: return allocator specific cookie for a given memory buffer 68 * @cookie: return allocator specific cookie for a given memory buffer
69 * associated with the passed private structure or NULL if not 69 * associated with the passed private structure or NULL if not
70 * available 70 * available.
71 * @num_users: return the current number of users of a memory buffer; 71 * @num_users: return the current number of users of a memory buffer;
72 * return 1 if the videobuf layer (or actually the driver using 72 * return 1 if the videobuf layer (or actually the driver using
73 * it) is the only user 73 * it) is the only user.
74 * @mmap: setup a userspace mapping for a given memory buffer under 74 * @mmap: setup a userspace mapping for a given memory buffer under
75 * the provided virtual memory region 75 * the provided virtual memory region.
76 * 76 *
77 * Required ops for USERPTR types: get_userptr, put_userptr. 77 * Required ops for USERPTR types: get_userptr, put_userptr.
78 * Required ops for MMAP types: alloc, put, num_users, mmap. 78 * Required ops for MMAP types: alloc, put, num_users, mmap.
79 * Required ops for read/write access types: alloc, put, num_users, vaddr 79 * Required ops for read/write access types: alloc, put, num_users, vaddr.
80 * Required ops for DMABUF types: attach_dmabuf, detach_dmabuf, map_dmabuf, 80 * Required ops for DMABUF types: attach_dmabuf, detach_dmabuf, map_dmabuf,
81 * unmap_dmabuf. 81 * unmap_dmabuf.
82 */ 82 */
@@ -203,6 +203,37 @@ struct vb2_buffer {
203 struct list_head done_entry; 203 struct list_head done_entry;
204 204
205 struct vb2_plane planes[VIDEO_MAX_PLANES]; 205 struct vb2_plane planes[VIDEO_MAX_PLANES];
206
207#ifdef CONFIG_VIDEO_ADV_DEBUG
208 /*
209 * Counters for how often these buffer-related ops are
210 * called. Used to check for unbalanced ops.
211 */
212 u32 cnt_mem_alloc;
213 u32 cnt_mem_put;
214 u32 cnt_mem_get_dmabuf;
215 u32 cnt_mem_get_userptr;
216 u32 cnt_mem_put_userptr;
217 u32 cnt_mem_prepare;
218 u32 cnt_mem_finish;
219 u32 cnt_mem_attach_dmabuf;
220 u32 cnt_mem_detach_dmabuf;
221 u32 cnt_mem_map_dmabuf;
222 u32 cnt_mem_unmap_dmabuf;
223 u32 cnt_mem_vaddr;
224 u32 cnt_mem_cookie;
225 u32 cnt_mem_num_users;
226 u32 cnt_mem_mmap;
227
228 u32 cnt_buf_init;
229 u32 cnt_buf_prepare;
230 u32 cnt_buf_finish;
231 u32 cnt_buf_cleanup;
232 u32 cnt_buf_queue;
233
234 /* This counts the number of calls to vb2_buffer_done() */
235 u32 cnt_buf_done;
236#endif
206}; 237};
207 238
208/** 239/**
@@ -227,27 +258,35 @@ struct vb2_buffer {
227 * @wait_prepare: release any locks taken while calling vb2 functions; 258 * @wait_prepare: release any locks taken while calling vb2 functions;
228 * it is called before an ioctl needs to wait for a new 259 * it is called before an ioctl needs to wait for a new
229 * buffer to arrive; required to avoid a deadlock in 260 * buffer to arrive; required to avoid a deadlock in
230 * blocking access type 261 * blocking access type.
231 * @wait_finish: reacquire all locks released in the previous callback; 262 * @wait_finish: reacquire all locks released in the previous callback;
232 * required to continue operation after sleeping while 263 * required to continue operation after sleeping while
233 * waiting for a new buffer to arrive 264 * waiting for a new buffer to arrive.
234 * @buf_init: called once after allocating a buffer (in MMAP case) 265 * @buf_init: called once after allocating a buffer (in MMAP case)
235 * or after acquiring a new USERPTR buffer; drivers may 266 * or after acquiring a new USERPTR buffer; drivers may
236 * perform additional buffer-related initialization; 267 * perform additional buffer-related initialization;
237 * initialization failure (return != 0) will prevent 268 * initialization failure (return != 0) will prevent
238 * queue setup from completing successfully; optional 269 * queue setup from completing successfully; optional.
239 * @buf_prepare: called every time the buffer is queued from userspace 270 * @buf_prepare: called every time the buffer is queued from userspace
240 * and from the VIDIOC_PREPARE_BUF ioctl; drivers may 271 * and from the VIDIOC_PREPARE_BUF ioctl; drivers may
241 * perform any initialization required before each hardware 272 * perform any initialization required before each hardware
242 * operation in this callback; drivers that support 273 * operation in this callback; drivers that support
243 * VIDIOC_CREATE_BUFS must also validate the buffer size; 274 * VIDIOC_CREATE_BUFS must also validate the buffer size;
244 * if an error is returned, the buffer will not be queued 275 * if an error is returned, the buffer will not be queued
245 * in driver; optional 276 * in driver; optional.
246 * @buf_finish: called before every dequeue of the buffer back to 277 * @buf_finish: called before every dequeue of the buffer back to
247 * userspace; drivers may perform any operations required 278 * userspace; drivers may perform any operations required
248 * before userspace accesses the buffer; optional 279 * before userspace accesses the buffer; optional. The
280 * buffer state can be one of the following: DONE and
281 * ERROR occur while streaming is in progress, and the
282 * PREPARED state occurs when the queue has been canceled
283 * and all pending buffers are being returned to their
284 * default DEQUEUED state. Typically you only have to do
285 * something if the state is VB2_BUF_STATE_DONE, since in
286 * all other cases the buffer contents will be ignored
287 * anyway.
249 * @buf_cleanup: called once before the buffer is freed; drivers may 288 * @buf_cleanup: called once before the buffer is freed; drivers may
250 * perform any additional cleanup; optional 289 * perform any additional cleanup; optional.
251 * @start_streaming: called once to enter 'streaming' state; the driver may 290 * @start_streaming: called once to enter 'streaming' state; the driver may
252 * receive buffers with @buf_queue callback before 291 * receive buffers with @buf_queue callback before
253 * @start_streaming is called; the driver gets the number 292 * @start_streaming is called; the driver gets the number
@@ -268,7 +307,7 @@ struct vb2_buffer {
268 * the buffer back by calling vb2_buffer_done() function; 307 * the buffer back by calling vb2_buffer_done() function;
269 * it is allways called after calling STREAMON ioctl; 308 * it is allways called after calling STREAMON ioctl;
270 * might be called before start_streaming callback if user 309 * might be called before start_streaming callback if user
271 * pre-queued buffers before calling STREAMON 310 * pre-queued buffers before calling STREAMON.
272 */ 311 */
273struct vb2_ops { 312struct vb2_ops {
274 int (*queue_setup)(struct vb2_queue *q, const struct v4l2_format *fmt, 313 int (*queue_setup)(struct vb2_queue *q, const struct v4l2_format *fmt,
@@ -280,7 +319,7 @@ struct vb2_ops {
280 319
281 int (*buf_init)(struct vb2_buffer *vb); 320 int (*buf_init)(struct vb2_buffer *vb);
282 int (*buf_prepare)(struct vb2_buffer *vb); 321 int (*buf_prepare)(struct vb2_buffer *vb);
283 int (*buf_finish)(struct vb2_buffer *vb); 322 void (*buf_finish)(struct vb2_buffer *vb);
284 void (*buf_cleanup)(struct vb2_buffer *vb); 323 void (*buf_cleanup)(struct vb2_buffer *vb);
285 324
286 int (*start_streaming)(struct vb2_queue *q, unsigned int count); 325 int (*start_streaming)(struct vb2_queue *q, unsigned int count);
@@ -312,23 +351,29 @@ struct v4l2_fh;
312 * @buf_struct_size: size of the driver-specific buffer structure; 351 * @buf_struct_size: size of the driver-specific buffer structure;
313 * "0" indicates the driver doesn't want to use a custom buffer 352 * "0" indicates the driver doesn't want to use a custom buffer
314 * structure type, so sizeof(struct vb2_buffer) will is used 353 * structure type, so sizeof(struct vb2_buffer) will is used
354 * @timestamp_flags: Timestamp flags; V4L2_BUF_FLAGS_TIMESTAMP_* and
355 * V4L2_BUF_FLAGS_TSTAMP_SRC_*
315 * @gfp_flags: additional gfp flags used when allocating the buffers. 356 * @gfp_flags: additional gfp flags used when allocating the buffers.
316 * Typically this is 0, but it may be e.g. GFP_DMA or __GFP_DMA32 357 * Typically this is 0, but it may be e.g. GFP_DMA or __GFP_DMA32
317 * to force the buffer allocation to a specific memory zone. 358 * to force the buffer allocation to a specific memory zone.
359 * @min_buffers_needed: the minimum number of buffers needed before
360 * start_streaming() can be called. Used when a DMA engine
361 * cannot be started unless at least this number of buffers
362 * have been queued into the driver.
318 * 363 *
319 * @memory: current memory type used 364 * @memory: current memory type used
320 * @bufs: videobuf buffer structures 365 * @bufs: videobuf buffer structures
321 * @num_buffers: number of allocated/used buffers 366 * @num_buffers: number of allocated/used buffers
322 * @queued_list: list of buffers currently queued from userspace 367 * @queued_list: list of buffers currently queued from userspace
323 * @queued_count: number of buffers owned by the driver 368 * @queued_count: number of buffers queued and ready for streaming.
369 * @owned_by_drv_count: number of buffers owned by the driver
324 * @done_list: list of buffers ready to be dequeued to userspace 370 * @done_list: list of buffers ready to be dequeued to userspace
325 * @done_lock: lock to protect done_list list 371 * @done_lock: lock to protect done_list list
326 * @done_wq: waitqueue for processes waiting for buffers ready to be dequeued 372 * @done_wq: waitqueue for processes waiting for buffers ready to be dequeued
327 * @alloc_ctx: memory type/allocator-specific contexts for each plane 373 * @alloc_ctx: memory type/allocator-specific contexts for each plane
328 * @streaming: current streaming state 374 * @streaming: current streaming state
329 * @retry_start_streaming: start_streaming() was called, but there were not enough 375 * @start_streaming_called: start_streaming() was called successfully and we
330 * buffers queued. If set, then retry calling start_streaming when 376 * started streaming.
331 * queuing a new buffer.
332 * @fileio: file io emulator internal data, used only if emulator is active 377 * @fileio: file io emulator internal data, used only if emulator is active
333 */ 378 */
334struct vb2_queue { 379struct vb2_queue {
@@ -342,8 +387,9 @@ struct vb2_queue {
342 const struct vb2_mem_ops *mem_ops; 387 const struct vb2_mem_ops *mem_ops;
343 void *drv_priv; 388 void *drv_priv;
344 unsigned int buf_struct_size; 389 unsigned int buf_struct_size;
345 u32 timestamp_type; 390 u32 timestamp_flags;
346 gfp_t gfp_flags; 391 gfp_t gfp_flags;
392 u32 min_buffers_needed;
347 393
348/* private: internal use only */ 394/* private: internal use only */
349 enum v4l2_memory memory; 395 enum v4l2_memory memory;
@@ -351,8 +397,9 @@ struct vb2_queue {
351 unsigned int num_buffers; 397 unsigned int num_buffers;
352 398
353 struct list_head queued_list; 399 struct list_head queued_list;
400 unsigned int queued_count;
354 401
355 atomic_t queued_count; 402 atomic_t owned_by_drv_count;
356 struct list_head done_list; 403 struct list_head done_list;
357 spinlock_t done_lock; 404 spinlock_t done_lock;
358 wait_queue_head_t done_wq; 405 wait_queue_head_t done_wq;
@@ -361,9 +408,21 @@ struct vb2_queue {
361 unsigned int plane_sizes[VIDEO_MAX_PLANES]; 408 unsigned int plane_sizes[VIDEO_MAX_PLANES];
362 409
363 unsigned int streaming:1; 410 unsigned int streaming:1;
364 unsigned int retry_start_streaming:1; 411 unsigned int start_streaming_called:1;
365 412
366 struct vb2_fileio_data *fileio; 413 struct vb2_fileio_data *fileio;
414
415#ifdef CONFIG_VIDEO_ADV_DEBUG
416 /*
417 * Counters for how often these queue-related ops are
418 * called. Used to check for unbalanced ops.
419 */
420 u32 cnt_queue_setup;
421 u32 cnt_wait_prepare;
422 u32 cnt_wait_finish;
423 u32 cnt_start_streaming;
424 u32 cnt_stop_streaming;
425#endif
367}; 426};
368 427
369void *vb2_plane_vaddr(struct vb2_buffer *vb, unsigned int plane_no); 428void *vb2_plane_vaddr(struct vb2_buffer *vb, unsigned int plane_no);