aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/asm-generic/pci_iomap.h6
-rw-r--r--include/linux/dcache.h2
-rw-r--r--include/linux/kfifo.h3
-rw-r--r--include/linux/led-class-flash.h4
-rw-r--r--include/linux/libnvdimm.h11
-rw-r--r--include/linux/memory_hotplug.h29
-rw-r--r--include/linux/memremap.h77
-rw-r--r--include/linux/mlx5/driver.h2
-rw-r--r--include/linux/mm.h22
-rw-r--r--include/linux/of_pci.h8
-rw-r--r--include/linux/pci-aspm.h35
-rw-r--r--include/linux/pci-dma-compat.h27
-rw-r--r--include/linux/pci-ecam.h13
-rw-r--r--include/linux/pci-ep-cfs.h5
-rw-r--r--include/linux/pci-epc.h48
-rw-r--r--include/linux/pci-epf.h5
-rw-r--r--include/linux/pci.h441
-rw-r--r--include/linux/pci_hotplug.h16
-rw-r--r--include/linux/pci_ids.h2
-rw-r--r--include/linux/pfn_t.h13
-rw-r--r--include/linux/platform_data/mlxcpld-hotplug.h99
-rw-r--r--include/linux/platform_data/mlxreg.h144
-rw-r--r--include/linux/remoteproc.h21
-rw-r--r--include/linux/switchtec.h3
-rw-r--r--include/media/cec.h18
-rw-r--r--include/media/demux.h589
-rw-r--r--include/media/dmxdev.h212
-rw-r--r--include/media/drv-intf/cx2341x.h144
-rw-r--r--include/media/drv-intf/exynos-fimc.h3
-rw-r--r--include/media/drv-intf/msp3400.h62
-rw-r--r--include/media/drv-intf/saa7146.h2
-rw-r--r--include/media/dvb-usb-ids.h424
-rw-r--r--include/media/dvb_ca_en50221.h142
-rw-r--r--include/media/dvb_demux.h350
-rw-r--r--include/media/dvb_frontend.h795
-rw-r--r--include/media/dvb_math.h66
-rw-r--r--include/media/dvb_net.h93
-rw-r--r--include/media/dvb_ringbuffer.h280
-rw-r--r--include/media/dvb_vb2.h266
-rw-r--r--include/media/dvbdev.h407
-rw-r--r--include/media/i2c-addr.h43
-rw-r--r--include/media/i2c/as3645a.h66
-rw-r--r--include/media/i2c/bt819.h4
-rw-r--r--include/media/i2c/ir-kbd-i2c.h6
-rw-r--r--include/media/i2c/m52790.h52
-rw-r--r--include/media/i2c/saa7115.h12
-rw-r--r--include/media/i2c/tvaudio.h17
-rw-r--r--include/media/i2c/upd64031a.h6
-rw-r--r--include/media/lirc.h1
-rw-r--r--include/media/lirc_dev.h192
-rw-r--r--include/media/media-entity.h11
-rw-r--r--include/media/rc-core.h69
-rw-r--r--include/media/rc-map.h54
-rw-r--r--include/media/tpg/v4l2-tpg.h (renamed from include/media/v4l2-tpg.h)45
-rw-r--r--include/media/tuner-types.h15
-rw-r--r--include/media/v4l2-async.h39
-rw-r--r--include/media/v4l2-common.h145
-rw-r--r--include/media/v4l2-ctrls.h11
-rw-r--r--include/media/v4l2-dev.h140
-rw-r--r--include/media/v4l2-device.h246
-rw-r--r--include/media/v4l2-dv-timings.h16
-rw-r--r--include/media/v4l2-event.h36
-rw-r--r--include/media/v4l2-flash-led-class.h12
-rw-r--r--include/media/v4l2-fwnode.h12
-rw-r--r--include/media/v4l2-mediabus.h80
-rw-r--r--include/media/v4l2-subdev.h150
-rw-r--r--include/media/v4l2-tpg-colors.h68
-rw-r--r--include/media/videobuf-dvb.h10
-rw-r--r--include/media/videobuf2-core.h519
-rw-r--r--include/media/videobuf2-dvb.h11
-rw-r--r--include/media/videobuf2-memops.h8
-rw-r--r--include/media/videobuf2-v4l2.h112
-rw-r--r--include/rdma/ib_hdrs.h19
-rw-r--r--include/rdma/ib_verbs.h20
-rw-r--r--include/uapi/linux/dvb/dmx.h63
-rw-r--r--include/uapi/linux/dvb/frontend.h40
-rw-r--r--include/uapi/linux/dvb/version.h2
-rw-r--r--include/uapi/linux/dvb/video.h20
-rw-r--r--include/uapi/linux/input-event-codes.h1
-rw-r--r--include/uapi/linux/lirc.h82
-rw-r--r--include/uapi/linux/ndctl.h56
-rw-r--r--include/uapi/linux/pci_regs.h30
-rw-r--r--include/uapi/linux/switchtec_ioctl.h3
-rw-r--r--include/uapi/linux/uvcvideo.h26
-rw-r--r--include/uapi/linux/v4l2-controls.h96
-rw-r--r--include/uapi/linux/videodev2.h63
-rw-r--r--include/uapi/rdma/rdma_netlink.h14
87 files changed, 5798 insertions, 1834 deletions
diff --git a/include/asm-generic/pci_iomap.h b/include/asm-generic/pci_iomap.h
index b1e17fcee2d0..854f96ad5ccb 100644
--- a/include/asm-generic/pci_iomap.h
+++ b/include/asm-generic/pci_iomap.h
@@ -1,12 +1,8 @@
1/* SPDX-License-Identifier: GPL-2.0+ */
1/* Generic I/O port emulation, based on MN10300 code 2/* Generic I/O port emulation, based on MN10300 code
2 * 3 *
3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. 4 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com) 5 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
10 */ 6 */
11#ifndef __ASM_GENERIC_PCI_IOMAP_H 7#ifndef __ASM_GENERIC_PCI_IOMAP_H
12#define __ASM_GENERIC_PCI_IOMAP_H 8#define __ASM_GENERIC_PCI_IOMAP_H
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index 65cd8ab60b7a..82a99d366aec 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -227,6 +227,7 @@ extern seqlock_t rename_lock;
227 */ 227 */
228extern void d_instantiate(struct dentry *, struct inode *); 228extern void d_instantiate(struct dentry *, struct inode *);
229extern struct dentry * d_instantiate_unique(struct dentry *, struct inode *); 229extern struct dentry * d_instantiate_unique(struct dentry *, struct inode *);
230extern struct dentry * d_instantiate_anon(struct dentry *, struct inode *);
230extern int d_instantiate_no_diralias(struct dentry *, struct inode *); 231extern int d_instantiate_no_diralias(struct dentry *, struct inode *);
231extern void __d_drop(struct dentry *dentry); 232extern void __d_drop(struct dentry *dentry);
232extern void d_drop(struct dentry *dentry); 233extern void d_drop(struct dentry *dentry);
@@ -235,6 +236,7 @@ extern void d_set_d_op(struct dentry *dentry, const struct dentry_operations *op
235 236
236/* allocate/de-allocate */ 237/* allocate/de-allocate */
237extern struct dentry * d_alloc(struct dentry *, const struct qstr *); 238extern struct dentry * d_alloc(struct dentry *, const struct qstr *);
239extern struct dentry * d_alloc_anon(struct super_block *);
238extern struct dentry * d_alloc_pseudo(struct super_block *, const struct qstr *); 240extern struct dentry * d_alloc_pseudo(struct super_block *, const struct qstr *);
239extern struct dentry * d_alloc_parallel(struct dentry *, const struct qstr *, 241extern struct dentry * d_alloc_parallel(struct dentry *, const struct qstr *,
240 wait_queue_head_t *); 242 wait_queue_head_t *);
diff --git a/include/linux/kfifo.h b/include/linux/kfifo.h
index 7b45959ebd92..e251533a5939 100644
--- a/include/linux/kfifo.h
+++ b/include/linux/kfifo.h
@@ -113,7 +113,8 @@ struct kfifo_rec_ptr_2 __STRUCT_KFIFO_PTR(unsigned char, 2, void);
113 * array is a part of the structure and the fifo type where the array is 113 * array is a part of the structure and the fifo type where the array is
114 * outside of the fifo structure. 114 * outside of the fifo structure.
115 */ 115 */
116#define __is_kfifo_ptr(fifo) (sizeof(*fifo) == sizeof(struct __kfifo)) 116#define __is_kfifo_ptr(fifo) \
117 (sizeof(*fifo) == sizeof(STRUCT_KFIFO_PTR(typeof(*(fifo)->type))))
117 118
118/** 119/**
119 * DECLARE_KFIFO_PTR - macro to declare a fifo pointer object 120 * DECLARE_KFIFO_PTR - macro to declare a fifo pointer object
diff --git a/include/linux/led-class-flash.h b/include/linux/led-class-flash.h
index e97966d1fb8d..700efaa9e115 100644
--- a/include/linux/led-class-flash.h
+++ b/include/linux/led-class-flash.h
@@ -121,6 +121,8 @@ extern void led_classdev_flash_unregister(struct led_classdev_flash *fled_cdev);
121static inline int led_set_flash_strobe(struct led_classdev_flash *fled_cdev, 121static inline int led_set_flash_strobe(struct led_classdev_flash *fled_cdev,
122 bool state) 122 bool state)
123{ 123{
124 if (!fled_cdev)
125 return -EINVAL;
124 return fled_cdev->ops->strobe_set(fled_cdev, state); 126 return fled_cdev->ops->strobe_set(fled_cdev, state);
125} 127}
126 128
@@ -136,6 +138,8 @@ static inline int led_set_flash_strobe(struct led_classdev_flash *fled_cdev,
136static inline int led_get_flash_strobe(struct led_classdev_flash *fled_cdev, 138static inline int led_get_flash_strobe(struct led_classdev_flash *fled_cdev,
137 bool *state) 139 bool *state)
138{ 140{
141 if (!fled_cdev)
142 return -EINVAL;
139 if (fled_cdev->ops->strobe_get) 143 if (fled_cdev->ops->strobe_get)
140 return fled_cdev->ops->strobe_get(fled_cdev, state); 144 return fled_cdev->ops->strobe_get(fled_cdev, state);
141 145
diff --git a/include/linux/libnvdimm.h b/include/linux/libnvdimm.h
index f8109ddb5ef1..ff855ed965fb 100644
--- a/include/linux/libnvdimm.h
+++ b/include/linux/libnvdimm.h
@@ -47,6 +47,17 @@ enum {
47 47
48 /* region flag indicating to direct-map persistent memory by default */ 48 /* region flag indicating to direct-map persistent memory by default */
49 ND_REGION_PAGEMAP = 0, 49 ND_REGION_PAGEMAP = 0,
50 /*
51 * Platform ensures entire CPU store data path is flushed to pmem on
52 * system power loss.
53 */
54 ND_REGION_PERSIST_CACHE = 1,
55 /*
56 * Platform provides mechanisms to automatically flush outstanding
57 * write data from memory controler to pmem on system power loss.
58 * (ADR)
59 */
60 ND_REGION_PERSIST_MEMCTRL = 2,
50 61
51 /* mark newly adjusted resources as requiring a label update */ 62 /* mark newly adjusted resources as requiring a label update */
52 DPA_RESOURCE_ADJUSTED = 1 << 0, 63 DPA_RESOURCE_ADJUSTED = 1 << 0,
diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h
index 58e110aee7ab..aba5f86eb038 100644
--- a/include/linux/memory_hotplug.h
+++ b/include/linux/memory_hotplug.h
@@ -13,6 +13,7 @@ struct pglist_data;
13struct mem_section; 13struct mem_section;
14struct memory_block; 14struct memory_block;
15struct resource; 15struct resource;
16struct vmem_altmap;
16 17
17#ifdef CONFIG_MEMORY_HOTPLUG 18#ifdef CONFIG_MEMORY_HOTPLUG
18/* 19/*
@@ -125,24 +126,26 @@ static inline bool movable_node_is_enabled(void)
125 126
126#ifdef CONFIG_MEMORY_HOTREMOVE 127#ifdef CONFIG_MEMORY_HOTREMOVE
127extern bool is_pageblock_removable_nolock(struct page *page); 128extern bool is_pageblock_removable_nolock(struct page *page);
128extern int arch_remove_memory(u64 start, u64 size); 129extern int arch_remove_memory(u64 start, u64 size,
130 struct vmem_altmap *altmap);
129extern int __remove_pages(struct zone *zone, unsigned long start_pfn, 131extern int __remove_pages(struct zone *zone, unsigned long start_pfn,
130 unsigned long nr_pages); 132 unsigned long nr_pages, struct vmem_altmap *altmap);
131#endif /* CONFIG_MEMORY_HOTREMOVE */ 133#endif /* CONFIG_MEMORY_HOTREMOVE */
132 134
133/* reasonably generic interface to expand the physical pages */ 135/* reasonably generic interface to expand the physical pages */
134extern int __add_pages(int nid, unsigned long start_pfn, 136extern int __add_pages(int nid, unsigned long start_pfn, unsigned long nr_pages,
135 unsigned long nr_pages, bool want_memblock); 137 struct vmem_altmap *altmap, bool want_memblock);
136 138
137#ifndef CONFIG_ARCH_HAS_ADD_PAGES 139#ifndef CONFIG_ARCH_HAS_ADD_PAGES
138static inline int add_pages(int nid, unsigned long start_pfn, 140static inline int add_pages(int nid, unsigned long start_pfn,
139 unsigned long nr_pages, bool want_memblock) 141 unsigned long nr_pages, struct vmem_altmap *altmap,
142 bool want_memblock)
140{ 143{
141 return __add_pages(nid, start_pfn, nr_pages, want_memblock); 144 return __add_pages(nid, start_pfn, nr_pages, altmap, want_memblock);
142} 145}
143#else /* ARCH_HAS_ADD_PAGES */ 146#else /* ARCH_HAS_ADD_PAGES */
144int add_pages(int nid, unsigned long start_pfn, 147int add_pages(int nid, unsigned long start_pfn, unsigned long nr_pages,
145 unsigned long nr_pages, bool want_memblock); 148 struct vmem_altmap *altmap, bool want_memblock);
146#endif /* ARCH_HAS_ADD_PAGES */ 149#endif /* ARCH_HAS_ADD_PAGES */
147 150
148#ifdef CONFIG_NUMA 151#ifdef CONFIG_NUMA
@@ -318,15 +321,17 @@ extern int walk_memory_range(unsigned long start_pfn, unsigned long end_pfn,
318 void *arg, int (*func)(struct memory_block *, void *)); 321 void *arg, int (*func)(struct memory_block *, void *));
319extern int add_memory(int nid, u64 start, u64 size); 322extern int add_memory(int nid, u64 start, u64 size);
320extern int add_memory_resource(int nid, struct resource *resource, bool online); 323extern int add_memory_resource(int nid, struct resource *resource, bool online);
321extern int arch_add_memory(int nid, u64 start, u64 size, bool want_memblock); 324extern int arch_add_memory(int nid, u64 start, u64 size,
325 struct vmem_altmap *altmap, bool want_memblock);
322extern void move_pfn_range_to_zone(struct zone *zone, unsigned long start_pfn, 326extern void move_pfn_range_to_zone(struct zone *zone, unsigned long start_pfn,
323 unsigned long nr_pages); 327 unsigned long nr_pages, struct vmem_altmap *altmap);
324extern int offline_pages(unsigned long start_pfn, unsigned long nr_pages); 328extern int offline_pages(unsigned long start_pfn, unsigned long nr_pages);
325extern bool is_memblock_offlined(struct memory_block *mem); 329extern bool is_memblock_offlined(struct memory_block *mem);
326extern void remove_memory(int nid, u64 start, u64 size); 330extern void remove_memory(int nid, u64 start, u64 size);
327extern int sparse_add_one_section(struct pglist_data *pgdat, unsigned long start_pfn); 331extern int sparse_add_one_section(struct pglist_data *pgdat,
332 unsigned long start_pfn, struct vmem_altmap *altmap);
328extern void sparse_remove_one_section(struct zone *zone, struct mem_section *ms, 333extern void sparse_remove_one_section(struct zone *zone, struct mem_section *ms,
329 unsigned long map_offset); 334 unsigned long map_offset, struct vmem_altmap *altmap);
330extern struct page *sparse_decode_mem_map(unsigned long coded_mem_map, 335extern struct page *sparse_decode_mem_map(unsigned long coded_mem_map,
331 unsigned long pnum); 336 unsigned long pnum);
332extern bool allow_online_pfn_range(int nid, unsigned long pfn, unsigned long nr_pages, 337extern bool allow_online_pfn_range(int nid, unsigned long pfn, unsigned long nr_pages,
diff --git a/include/linux/memremap.h b/include/linux/memremap.h
index 10d23c367048..7b4899c06f49 100644
--- a/include/linux/memremap.h
+++ b/include/linux/memremap.h
@@ -26,18 +26,6 @@ struct vmem_altmap {
26 unsigned long alloc; 26 unsigned long alloc;
27}; 27};
28 28
29unsigned long vmem_altmap_offset(struct vmem_altmap *altmap);
30void vmem_altmap_free(struct vmem_altmap *altmap, unsigned long nr_pfns);
31
32#ifdef CONFIG_ZONE_DEVICE
33struct vmem_altmap *to_vmem_altmap(unsigned long memmap_start);
34#else
35static inline struct vmem_altmap *to_vmem_altmap(unsigned long memmap_start)
36{
37 return NULL;
38}
39#endif
40
41/* 29/*
42 * Specialize ZONE_DEVICE memory into multiple types each having differents 30 * Specialize ZONE_DEVICE memory into multiple types each having differents
43 * usage. 31 * usage.
@@ -125,8 +113,9 @@ typedef void (*dev_page_free_t)(struct page *page, void *data);
125struct dev_pagemap { 113struct dev_pagemap {
126 dev_page_fault_t page_fault; 114 dev_page_fault_t page_fault;
127 dev_page_free_t page_free; 115 dev_page_free_t page_free;
128 struct vmem_altmap *altmap; 116 struct vmem_altmap altmap;
129 const struct resource *res; 117 bool altmap_valid;
118 struct resource res;
130 struct percpu_ref *ref; 119 struct percpu_ref *ref;
131 struct device *dev; 120 struct device *dev;
132 void *data; 121 void *data;
@@ -134,15 +123,17 @@ struct dev_pagemap {
134}; 123};
135 124
136#ifdef CONFIG_ZONE_DEVICE 125#ifdef CONFIG_ZONE_DEVICE
137void *devm_memremap_pages(struct device *dev, struct resource *res, 126void *devm_memremap_pages(struct device *dev, struct dev_pagemap *pgmap);
138 struct percpu_ref *ref, struct vmem_altmap *altmap); 127struct dev_pagemap *get_dev_pagemap(unsigned long pfn,
139struct dev_pagemap *find_dev_pagemap(resource_size_t phys); 128 struct dev_pagemap *pgmap);
129
130unsigned long vmem_altmap_offset(struct vmem_altmap *altmap);
131void vmem_altmap_free(struct vmem_altmap *altmap, unsigned long nr_pfns);
140 132
141static inline bool is_zone_device_page(const struct page *page); 133static inline bool is_zone_device_page(const struct page *page);
142#else 134#else
143static inline void *devm_memremap_pages(struct device *dev, 135static inline void *devm_memremap_pages(struct device *dev,
144 struct resource *res, struct percpu_ref *ref, 136 struct dev_pagemap *pgmap)
145 struct vmem_altmap *altmap)
146{ 137{
147 /* 138 /*
148 * Fail attempts to call devm_memremap_pages() without 139 * Fail attempts to call devm_memremap_pages() without
@@ -153,11 +144,22 @@ static inline void *devm_memremap_pages(struct device *dev,
153 return ERR_PTR(-ENXIO); 144 return ERR_PTR(-ENXIO);
154} 145}
155 146
156static inline struct dev_pagemap *find_dev_pagemap(resource_size_t phys) 147static inline struct dev_pagemap *get_dev_pagemap(unsigned long pfn,
148 struct dev_pagemap *pgmap)
157{ 149{
158 return NULL; 150 return NULL;
159} 151}
160#endif 152
153static inline unsigned long vmem_altmap_offset(struct vmem_altmap *altmap)
154{
155 return 0;
156}
157
158static inline void vmem_altmap_free(struct vmem_altmap *altmap,
159 unsigned long nr_pfns)
160{
161}
162#endif /* CONFIG_ZONE_DEVICE */
161 163
162#if defined(CONFIG_DEVICE_PRIVATE) || defined(CONFIG_DEVICE_PUBLIC) 164#if defined(CONFIG_DEVICE_PRIVATE) || defined(CONFIG_DEVICE_PUBLIC)
163static inline bool is_device_private_page(const struct page *page) 165static inline bool is_device_private_page(const struct page *page)
@@ -173,39 +175,6 @@ static inline bool is_device_public_page(const struct page *page)
173} 175}
174#endif /* CONFIG_DEVICE_PRIVATE || CONFIG_DEVICE_PUBLIC */ 176#endif /* CONFIG_DEVICE_PRIVATE || CONFIG_DEVICE_PUBLIC */
175 177
176/**
177 * get_dev_pagemap() - take a new live reference on the dev_pagemap for @pfn
178 * @pfn: page frame number to lookup page_map
179 * @pgmap: optional known pgmap that already has a reference
180 *
181 * @pgmap allows the overhead of a lookup to be bypassed when @pfn lands in the
182 * same mapping.
183 */
184static inline struct dev_pagemap *get_dev_pagemap(unsigned long pfn,
185 struct dev_pagemap *pgmap)
186{
187 const struct resource *res = pgmap ? pgmap->res : NULL;
188 resource_size_t phys = PFN_PHYS(pfn);
189
190 /*
191 * In the cached case we're already holding a live reference so
192 * we can simply do a blind increment
193 */
194 if (res && phys >= res->start && phys <= res->end) {
195 percpu_ref_get(pgmap->ref);
196 return pgmap;
197 }
198
199 /* fall back to slow path lookup */
200 rcu_read_lock();
201 pgmap = find_dev_pagemap(phys);
202 if (pgmap && !percpu_ref_tryget_live(pgmap->ref))
203 pgmap = NULL;
204 rcu_read_unlock();
205
206 return pgmap;
207}
208
209static inline void put_dev_pagemap(struct dev_pagemap *pgmap) 178static inline void put_dev_pagemap(struct dev_pagemap *pgmap)
210{ 179{
211 if (pgmap) 180 if (pgmap)
diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h
index fb7e8b205eb9..6ed79a8a8318 100644
--- a/include/linux/mlx5/driver.h
+++ b/include/linux/mlx5/driver.h
@@ -1277,7 +1277,7 @@ mlx5_get_vector_affinity(struct mlx5_core_dev *dev, int vector)
1277 int eqn; 1277 int eqn;
1278 int err; 1278 int err;
1279 1279
1280 err = mlx5_vector2eqn(dev, vector, &eqn, &irq); 1280 err = mlx5_vector2eqn(dev, MLX5_EQ_VEC_COMP_BASE + vector, &eqn, &irq);
1281 if (err) 1281 if (err)
1282 return NULL; 1282 return NULL;
1283 1283
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 173d2484f6e3..ad06d42adb1a 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2075,8 +2075,8 @@ static inline void zero_resv_unavail(void) {}
2075#endif 2075#endif
2076 2076
2077extern void set_dma_reserve(unsigned long new_dma_reserve); 2077extern void set_dma_reserve(unsigned long new_dma_reserve);
2078extern void memmap_init_zone(unsigned long, int, unsigned long, 2078extern void memmap_init_zone(unsigned long, int, unsigned long, unsigned long,
2079 unsigned long, enum memmap_context); 2079 enum memmap_context, struct vmem_altmap *);
2080extern void setup_per_zone_wmarks(void); 2080extern void setup_per_zone_wmarks(void);
2081extern int __meminit init_per_zone_wmark_min(void); 2081extern int __meminit init_per_zone_wmark_min(void);
2082extern void mem_init(void); 2082extern void mem_init(void);
@@ -2544,7 +2544,8 @@ void sparse_mem_maps_populate_node(struct page **map_map,
2544 unsigned long map_count, 2544 unsigned long map_count,
2545 int nodeid); 2545 int nodeid);
2546 2546
2547struct page *sparse_mem_map_populate(unsigned long pnum, int nid); 2547struct page *sparse_mem_map_populate(unsigned long pnum, int nid,
2548 struct vmem_altmap *altmap);
2548pgd_t *vmemmap_pgd_populate(unsigned long addr, int node); 2549pgd_t *vmemmap_pgd_populate(unsigned long addr, int node);
2549p4d_t *vmemmap_p4d_populate(pgd_t *pgd, unsigned long addr, int node); 2550p4d_t *vmemmap_p4d_populate(pgd_t *pgd, unsigned long addr, int node);
2550pud_t *vmemmap_pud_populate(p4d_t *p4d, unsigned long addr, int node); 2551pud_t *vmemmap_pud_populate(p4d_t *p4d, unsigned long addr, int node);
@@ -2552,20 +2553,17 @@ pmd_t *vmemmap_pmd_populate(pud_t *pud, unsigned long addr, int node);
2552pte_t *vmemmap_pte_populate(pmd_t *pmd, unsigned long addr, int node); 2553pte_t *vmemmap_pte_populate(pmd_t *pmd, unsigned long addr, int node);
2553void *vmemmap_alloc_block(unsigned long size, int node); 2554void *vmemmap_alloc_block(unsigned long size, int node);
2554struct vmem_altmap; 2555struct vmem_altmap;
2555void *__vmemmap_alloc_block_buf(unsigned long size, int node, 2556void *vmemmap_alloc_block_buf(unsigned long size, int node);
2556 struct vmem_altmap *altmap); 2557void *altmap_alloc_block_buf(unsigned long size, struct vmem_altmap *altmap);
2557static inline void *vmemmap_alloc_block_buf(unsigned long size, int node)
2558{
2559 return __vmemmap_alloc_block_buf(size, node, NULL);
2560}
2561
2562void vmemmap_verify(pte_t *, int, unsigned long, unsigned long); 2558void vmemmap_verify(pte_t *, int, unsigned long, unsigned long);
2563int vmemmap_populate_basepages(unsigned long start, unsigned long end, 2559int vmemmap_populate_basepages(unsigned long start, unsigned long end,
2564 int node); 2560 int node);
2565int vmemmap_populate(unsigned long start, unsigned long end, int node); 2561int vmemmap_populate(unsigned long start, unsigned long end, int node,
2562 struct vmem_altmap *altmap);
2566void vmemmap_populate_print_last(void); 2563void vmemmap_populate_print_last(void);
2567#ifdef CONFIG_MEMORY_HOTPLUG 2564#ifdef CONFIG_MEMORY_HOTPLUG
2568void vmemmap_free(unsigned long start, unsigned long end); 2565void vmemmap_free(unsigned long start, unsigned long end,
2566 struct vmem_altmap *altmap);
2569#endif 2567#endif
2570void register_page_bootmem_memmap(unsigned long section_nr, struct page *map, 2568void register_page_bootmem_memmap(unsigned long section_nr, struct page *map,
2571 unsigned long nr_pages); 2569 unsigned long nr_pages);
diff --git a/include/linux/of_pci.h b/include/linux/of_pci.h
index bf588a05d0d0..88865e0ebf4d 100644
--- a/include/linux/of_pci.h
+++ b/include/linux/of_pci.h
@@ -9,8 +9,7 @@ struct pci_dev;
9struct of_phandle_args; 9struct of_phandle_args;
10struct device_node; 10struct device_node;
11 11
12#ifdef CONFIG_OF_PCI 12#if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_PCI)
13int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq);
14struct device_node *of_pci_find_child_device(struct device_node *parent, 13struct device_node *of_pci_find_child_device(struct device_node *parent,
15 unsigned int devfn); 14 unsigned int devfn);
16int of_pci_get_devfn(struct device_node *np); 15int of_pci_get_devfn(struct device_node *np);
@@ -23,11 +22,6 @@ int of_pci_map_rid(struct device_node *np, u32 rid,
23 const char *map_name, const char *map_mask_name, 22 const char *map_name, const char *map_mask_name,
24 struct device_node **target, u32 *id_out); 23 struct device_node **target, u32 *id_out);
25#else 24#else
26static inline int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq)
27{
28 return 0;
29}
30
31static inline struct device_node *of_pci_find_child_device(struct device_node *parent, 25static inline struct device_node *of_pci_find_child_device(struct device_node *parent,
32 unsigned int devfn) 26 unsigned int devfn)
33{ 27{
diff --git a/include/linux/pci-aspm.h b/include/linux/pci-aspm.h
index 3cc06b059017..df28af5cef21 100644
--- a/include/linux/pci-aspm.h
+++ b/include/linux/pci-aspm.h
@@ -24,43 +24,12 @@
24#define PCIE_LINK_STATE_CLKPM 4 24#define PCIE_LINK_STATE_CLKPM 4
25 25
26#ifdef CONFIG_PCIEASPM 26#ifdef CONFIG_PCIEASPM
27void pcie_aspm_init_link_state(struct pci_dev *pdev);
28void pcie_aspm_exit_link_state(struct pci_dev *pdev);
29void pcie_aspm_pm_state_change(struct pci_dev *pdev);
30void pcie_aspm_powersave_config_link(struct pci_dev *pdev);
31void pci_disable_link_state(struct pci_dev *pdev, int state); 27void pci_disable_link_state(struct pci_dev *pdev, int state);
32void pci_disable_link_state_locked(struct pci_dev *pdev, int state); 28void pci_disable_link_state_locked(struct pci_dev *pdev, int state);
33void pcie_no_aspm(void); 29void pcie_no_aspm(void);
34#else 30#else
35static inline void pcie_aspm_init_link_state(struct pci_dev *pdev) 31static inline void pci_disable_link_state(struct pci_dev *pdev, int state) { }
36{ 32static inline void pcie_no_aspm(void) { }
37}
38static inline void pcie_aspm_exit_link_state(struct pci_dev *pdev)
39{
40}
41static inline void pcie_aspm_pm_state_change(struct pci_dev *pdev)
42{
43}
44static inline void pcie_aspm_powersave_config_link(struct pci_dev *pdev)
45{
46}
47static inline void pci_disable_link_state(struct pci_dev *pdev, int state)
48{
49}
50static inline void pcie_no_aspm(void)
51{
52}
53#endif 33#endif
54 34
55#ifdef CONFIG_PCIEASPM_DEBUG /* this depends on CONFIG_PCIEASPM */
56void pcie_aspm_create_sysfs_dev_files(struct pci_dev *pdev);
57void pcie_aspm_remove_sysfs_dev_files(struct pci_dev *pdev);
58#else
59static inline void pcie_aspm_create_sysfs_dev_files(struct pci_dev *pdev)
60{
61}
62static inline void pcie_aspm_remove_sysfs_dev_files(struct pci_dev *pdev)
63{
64}
65#endif
66#endif /* LINUX_ASPM_H */ 35#endif /* LINUX_ASPM_H */
diff --git a/include/linux/pci-dma-compat.h b/include/linux/pci-dma-compat.h
index d1f9fdade1e0..0dd1a3f7b309 100644
--- a/include/linux/pci-dma-compat.h
+++ b/include/linux/pci-dma-compat.h
@@ -17,91 +17,90 @@ static inline void *
17pci_alloc_consistent(struct pci_dev *hwdev, size_t size, 17pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
18 dma_addr_t *dma_handle) 18 dma_addr_t *dma_handle)
19{ 19{
20 return dma_alloc_coherent(hwdev == NULL ? NULL : &hwdev->dev, size, dma_handle, GFP_ATOMIC); 20 return dma_alloc_coherent(&hwdev->dev, size, dma_handle, GFP_ATOMIC);
21} 21}
22 22
23static inline void * 23static inline void *
24pci_zalloc_consistent(struct pci_dev *hwdev, size_t size, 24pci_zalloc_consistent(struct pci_dev *hwdev, size_t size,
25 dma_addr_t *dma_handle) 25 dma_addr_t *dma_handle)
26{ 26{
27 return dma_zalloc_coherent(hwdev == NULL ? NULL : &hwdev->dev, 27 return dma_zalloc_coherent(&hwdev->dev, size, dma_handle, GFP_ATOMIC);
28 size, dma_handle, GFP_ATOMIC);
29} 28}
30 29
31static inline void 30static inline void
32pci_free_consistent(struct pci_dev *hwdev, size_t size, 31pci_free_consistent(struct pci_dev *hwdev, size_t size,
33 void *vaddr, dma_addr_t dma_handle) 32 void *vaddr, dma_addr_t dma_handle)
34{ 33{
35 dma_free_coherent(hwdev == NULL ? NULL : &hwdev->dev, size, vaddr, dma_handle); 34 dma_free_coherent(&hwdev->dev, size, vaddr, dma_handle);
36} 35}
37 36
38static inline dma_addr_t 37static inline dma_addr_t
39pci_map_single(struct pci_dev *hwdev, void *ptr, size_t size, int direction) 38pci_map_single(struct pci_dev *hwdev, void *ptr, size_t size, int direction)
40{ 39{
41 return dma_map_single(hwdev == NULL ? NULL : &hwdev->dev, ptr, size, (enum dma_data_direction)direction); 40 return dma_map_single(&hwdev->dev, ptr, size, (enum dma_data_direction)direction);
42} 41}
43 42
44static inline void 43static inline void
45pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr, 44pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr,
46 size_t size, int direction) 45 size_t size, int direction)
47{ 46{
48 dma_unmap_single(hwdev == NULL ? NULL : &hwdev->dev, dma_addr, size, (enum dma_data_direction)direction); 47 dma_unmap_single(&hwdev->dev, dma_addr, size, (enum dma_data_direction)direction);
49} 48}
50 49
51static inline dma_addr_t 50static inline dma_addr_t
52pci_map_page(struct pci_dev *hwdev, struct page *page, 51pci_map_page(struct pci_dev *hwdev, struct page *page,
53 unsigned long offset, size_t size, int direction) 52 unsigned long offset, size_t size, int direction)
54{ 53{
55 return dma_map_page(hwdev == NULL ? NULL : &hwdev->dev, page, offset, size, (enum dma_data_direction)direction); 54 return dma_map_page(&hwdev->dev, page, offset, size, (enum dma_data_direction)direction);
56} 55}
57 56
58static inline void 57static inline void
59pci_unmap_page(struct pci_dev *hwdev, dma_addr_t dma_address, 58pci_unmap_page(struct pci_dev *hwdev, dma_addr_t dma_address,
60 size_t size, int direction) 59 size_t size, int direction)
61{ 60{
62 dma_unmap_page(hwdev == NULL ? NULL : &hwdev->dev, dma_address, size, (enum dma_data_direction)direction); 61 dma_unmap_page(&hwdev->dev, dma_address, size, (enum dma_data_direction)direction);
63} 62}
64 63
65static inline int 64static inline int
66pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg, 65pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg,
67 int nents, int direction) 66 int nents, int direction)
68{ 67{
69 return dma_map_sg(hwdev == NULL ? NULL : &hwdev->dev, sg, nents, (enum dma_data_direction)direction); 68 return dma_map_sg(&hwdev->dev, sg, nents, (enum dma_data_direction)direction);
70} 69}
71 70
72static inline void 71static inline void
73pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg, 72pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg,
74 int nents, int direction) 73 int nents, int direction)
75{ 74{
76 dma_unmap_sg(hwdev == NULL ? NULL : &hwdev->dev, sg, nents, (enum dma_data_direction)direction); 75 dma_unmap_sg(&hwdev->dev, sg, nents, (enum dma_data_direction)direction);
77} 76}
78 77
79static inline void 78static inline void
80pci_dma_sync_single_for_cpu(struct pci_dev *hwdev, dma_addr_t dma_handle, 79pci_dma_sync_single_for_cpu(struct pci_dev *hwdev, dma_addr_t dma_handle,
81 size_t size, int direction) 80 size_t size, int direction)
82{ 81{
83 dma_sync_single_for_cpu(hwdev == NULL ? NULL : &hwdev->dev, dma_handle, size, (enum dma_data_direction)direction); 82 dma_sync_single_for_cpu(&hwdev->dev, dma_handle, size, (enum dma_data_direction)direction);
84} 83}
85 84
86static inline void 85static inline void
87pci_dma_sync_single_for_device(struct pci_dev *hwdev, dma_addr_t dma_handle, 86pci_dma_sync_single_for_device(struct pci_dev *hwdev, dma_addr_t dma_handle,
88 size_t size, int direction) 87 size_t size, int direction)
89{ 88{
90 dma_sync_single_for_device(hwdev == NULL ? NULL : &hwdev->dev, dma_handle, size, (enum dma_data_direction)direction); 89 dma_sync_single_for_device(&hwdev->dev, dma_handle, size, (enum dma_data_direction)direction);
91} 90}
92 91
93static inline void 92static inline void
94pci_dma_sync_sg_for_cpu(struct pci_dev *hwdev, struct scatterlist *sg, 93pci_dma_sync_sg_for_cpu(struct pci_dev *hwdev, struct scatterlist *sg,
95 int nelems, int direction) 94 int nelems, int direction)
96{ 95{
97 dma_sync_sg_for_cpu(hwdev == NULL ? NULL : &hwdev->dev, sg, nelems, (enum dma_data_direction)direction); 96 dma_sync_sg_for_cpu(&hwdev->dev, sg, nelems, (enum dma_data_direction)direction);
98} 97}
99 98
100static inline void 99static inline void
101pci_dma_sync_sg_for_device(struct pci_dev *hwdev, struct scatterlist *sg, 100pci_dma_sync_sg_for_device(struct pci_dev *hwdev, struct scatterlist *sg,
102 int nelems, int direction) 101 int nelems, int direction)
103{ 102{
104 dma_sync_sg_for_device(hwdev == NULL ? NULL : &hwdev->dev, sg, nelems, (enum dma_data_direction)direction); 103 dma_sync_sg_for_device(&hwdev->dev, sg, nelems, (enum dma_data_direction)direction);
105} 104}
106 105
107static inline int 106static inline int
diff --git a/include/linux/pci-ecam.h b/include/linux/pci-ecam.h
index 809c2f1873ac..baadad1aabbc 100644
--- a/include/linux/pci-ecam.h
+++ b/include/linux/pci-ecam.h
@@ -1,17 +1,6 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * Copyright 2016 Broadcom 3 * Copyright 2016 Broadcom
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License, version 2, as
6 * published by the Free Software Foundation (the "GPL").
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License version 2 (GPLv2) for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * version 2 (GPLv2) along with this source code.
15 */ 4 */
16#ifndef DRIVERS_PCI_ECAM_H 5#ifndef DRIVERS_PCI_ECAM_H
17#define DRIVERS_PCI_ECAM_H 6#define DRIVERS_PCI_ECAM_H
diff --git a/include/linux/pci-ep-cfs.h b/include/linux/pci-ep-cfs.h
index 263b89ea5705..f42b0fd4b4bc 100644
--- a/include/linux/pci-ep-cfs.h
+++ b/include/linux/pci-ep-cfs.h
@@ -1,12 +1,9 @@
1/* SPDX-License-Identifier: GPL-2.0+ */
1/** 2/**
2 * PCI Endpoint ConfigFS header file 3 * PCI Endpoint ConfigFS header file
3 * 4 *
4 * Copyright (C) 2017 Texas Instruments 5 * Copyright (C) 2017 Texas Instruments
5 * Author: Kishon Vijay Abraham I <kishon@ti.com> 6 * Author: Kishon Vijay Abraham I <kishon@ti.com>
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 of
9 * the License as published by the Free Software Foundation.
10 */ 7 */
11 8
12#ifndef __LINUX_PCI_EP_CFS_H 9#ifndef __LINUX_PCI_EP_CFS_H
diff --git a/include/linux/pci-epc.h b/include/linux/pci-epc.h
index f7a04e1af112..a1a5e5df0f66 100644
--- a/include/linux/pci-epc.h
+++ b/include/linux/pci-epc.h
@@ -1,12 +1,9 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/** 2/**
2 * PCI Endpoint *Controller* (EPC) header file 3 * PCI Endpoint *Controller* (EPC) header file
3 * 4 *
4 * Copyright (C) 2017 Texas Instruments 5 * Copyright (C) 2017 Texas Instruments
5 * Author: Kishon Vijay Abraham I <kishon@ti.com> 6 * Author: Kishon Vijay Abraham I <kishon@ti.com>
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 of
9 * the License as published by the Free Software Foundation.
10 */ 7 */
11 8
12#ifndef __LINUX_PCI_EPC_H 9#ifndef __LINUX_PCI_EPC_H
@@ -39,17 +36,20 @@ enum pci_epc_irq_type {
39 * @owner: the module owner containing the ops 36 * @owner: the module owner containing the ops
40 */ 37 */
41struct pci_epc_ops { 38struct pci_epc_ops {
42 int (*write_header)(struct pci_epc *pci_epc, 39 int (*write_header)(struct pci_epc *epc, u8 func_no,
43 struct pci_epf_header *hdr); 40 struct pci_epf_header *hdr);
44 int (*set_bar)(struct pci_epc *epc, enum pci_barno bar, 41 int (*set_bar)(struct pci_epc *epc, u8 func_no,
42 enum pci_barno bar,
45 dma_addr_t bar_phys, size_t size, int flags); 43 dma_addr_t bar_phys, size_t size, int flags);
46 void (*clear_bar)(struct pci_epc *epc, enum pci_barno bar); 44 void (*clear_bar)(struct pci_epc *epc, u8 func_no,
47 int (*map_addr)(struct pci_epc *epc, phys_addr_t addr, 45 enum pci_barno bar);
48 u64 pci_addr, size_t size); 46 int (*map_addr)(struct pci_epc *epc, u8 func_no,
49 void (*unmap_addr)(struct pci_epc *epc, phys_addr_t addr); 47 phys_addr_t addr, u64 pci_addr, size_t size);
50 int (*set_msi)(struct pci_epc *epc, u8 interrupts); 48 void (*unmap_addr)(struct pci_epc *epc, u8 func_no,
51 int (*get_msi)(struct pci_epc *epc); 49 phys_addr_t addr);
52 int (*raise_irq)(struct pci_epc *pci_epc, 50 int (*set_msi)(struct pci_epc *epc, u8 func_no, u8 interrupts);
51 int (*get_msi)(struct pci_epc *epc, u8 func_no);
52 int (*raise_irq)(struct pci_epc *epc, u8 func_no,
53 enum pci_epc_irq_type type, u8 interrupt_num); 53 enum pci_epc_irq_type type, u8 interrupt_num);
54 int (*start)(struct pci_epc *epc); 54 int (*start)(struct pci_epc *epc);
55 void (*stop)(struct pci_epc *epc); 55 void (*stop)(struct pci_epc *epc);
@@ -124,17 +124,21 @@ void pci_epc_destroy(struct pci_epc *epc);
124int pci_epc_add_epf(struct pci_epc *epc, struct pci_epf *epf); 124int pci_epc_add_epf(struct pci_epc *epc, struct pci_epf *epf);
125void pci_epc_linkup(struct pci_epc *epc); 125void pci_epc_linkup(struct pci_epc *epc);
126void pci_epc_remove_epf(struct pci_epc *epc, struct pci_epf *epf); 126void pci_epc_remove_epf(struct pci_epc *epc, struct pci_epf *epf);
127int pci_epc_write_header(struct pci_epc *epc, struct pci_epf_header *hdr); 127int pci_epc_write_header(struct pci_epc *epc, u8 func_no,
128int pci_epc_set_bar(struct pci_epc *epc, enum pci_barno bar, 128 struct pci_epf_header *hdr);
129int pci_epc_set_bar(struct pci_epc *epc, u8 func_no,
130 enum pci_barno bar,
129 dma_addr_t bar_phys, size_t size, int flags); 131 dma_addr_t bar_phys, size_t size, int flags);
130void pci_epc_clear_bar(struct pci_epc *epc, int bar); 132void pci_epc_clear_bar(struct pci_epc *epc, u8 func_no, int bar);
131int pci_epc_map_addr(struct pci_epc *epc, phys_addr_t phys_addr, 133int pci_epc_map_addr(struct pci_epc *epc, u8 func_no,
134 phys_addr_t phys_addr,
132 u64 pci_addr, size_t size); 135 u64 pci_addr, size_t size);
133void pci_epc_unmap_addr(struct pci_epc *epc, phys_addr_t phys_addr); 136void pci_epc_unmap_addr(struct pci_epc *epc, u8 func_no,
134int pci_epc_set_msi(struct pci_epc *epc, u8 interrupts); 137 phys_addr_t phys_addr);
135int pci_epc_get_msi(struct pci_epc *epc); 138int pci_epc_set_msi(struct pci_epc *epc, u8 func_no, u8 interrupts);
136int pci_epc_raise_irq(struct pci_epc *epc, enum pci_epc_irq_type type, 139int pci_epc_get_msi(struct pci_epc *epc, u8 func_no);
137 u8 interrupt_num); 140int pci_epc_raise_irq(struct pci_epc *epc, u8 func_no,
141 enum pci_epc_irq_type type, u8 interrupt_num);
138int pci_epc_start(struct pci_epc *epc); 142int pci_epc_start(struct pci_epc *epc);
139void pci_epc_stop(struct pci_epc *epc); 143void pci_epc_stop(struct pci_epc *epc);
140struct pci_epc *pci_epc_get(const char *epc_name); 144struct pci_epc *pci_epc_get(const char *epc_name);
diff --git a/include/linux/pci-epf.h b/include/linux/pci-epf.h
index 60d551a9a1ba..e897bf076701 100644
--- a/include/linux/pci-epf.h
+++ b/include/linux/pci-epf.h
@@ -1,12 +1,9 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/** 2/**
2 * PCI Endpoint *Function* (EPF) header file 3 * PCI Endpoint *Function* (EPF) header file
3 * 4 *
4 * Copyright (C) 2017 Texas Instruments 5 * Copyright (C) 2017 Texas Instruments
5 * Author: Kishon Vijay Abraham I <kishon@ti.com> 6 * Author: Kishon Vijay Abraham I <kishon@ti.com>
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 of
9 * the License as published by the Free Software Foundation.
10 */ 7 */
11 8
12#ifndef __LINUX_PCI_EPF_H 9#ifndef __LINUX_PCI_EPF_H
diff --git a/include/linux/pci.h b/include/linux/pci.h
index ad35aac87971..024a1beda008 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -48,17 +48,17 @@
48 * In the interest of not exposing interfaces to user-space unnecessarily, 48 * In the interest of not exposing interfaces to user-space unnecessarily,
49 * the following kernel-only defines are being added here. 49 * the following kernel-only defines are being added here.
50 */ 50 */
51#define PCI_DEVID(bus, devfn) ((((u16)(bus)) << 8) | (devfn)) 51#define PCI_DEVID(bus, devfn) ((((u16)(bus)) << 8) | (devfn))
52/* return bus from PCI devid = ((u16)bus_number) << 8) | devfn */ 52/* return bus from PCI devid = ((u16)bus_number) << 8) | devfn */
53#define PCI_BUS_NUM(x) (((x) >> 8) & 0xff) 53#define PCI_BUS_NUM(x) (((x) >> 8) & 0xff)
54 54
55/* pci_slot represents a physical slot */ 55/* pci_slot represents a physical slot */
56struct pci_slot { 56struct pci_slot {
57 struct pci_bus *bus; /* The bus this slot is on */ 57 struct pci_bus *bus; /* Bus this slot is on */
58 struct list_head list; /* node in list of slots on this bus */ 58 struct list_head list; /* Node in list of slots */
59 struct hotplug_slot *hotplug; /* Hotplug info (migrate over time) */ 59 struct hotplug_slot *hotplug; /* Hotplug info (move here) */
60 unsigned char number; /* PCI_SLOT(pci_dev->devfn) */ 60 unsigned char number; /* PCI_SLOT(pci_dev->devfn) */
61 struct kobject kobj; 61 struct kobject kobj;
62}; 62};
63 63
64static inline const char *pci_slot_name(const struct pci_slot *slot) 64static inline const char *pci_slot_name(const struct pci_slot *slot)
@@ -72,9 +72,7 @@ enum pci_mmap_state {
72 pci_mmap_mem 72 pci_mmap_mem
73}; 73};
74 74
75/* 75/* For PCI devices, the region numbers are assigned this way: */
76 * For PCI devices, the region numbers are assigned this way:
77 */
78enum { 76enum {
79 /* #0-5: standard PCI resources */ 77 /* #0-5: standard PCI resources */
80 PCI_STD_RESOURCES, 78 PCI_STD_RESOURCES,
@@ -83,23 +81,23 @@ enum {
83 /* #6: expansion ROM resource */ 81 /* #6: expansion ROM resource */
84 PCI_ROM_RESOURCE, 82 PCI_ROM_RESOURCE,
85 83
86 /* device specific resources */ 84 /* Device-specific resources */
87#ifdef CONFIG_PCI_IOV 85#ifdef CONFIG_PCI_IOV
88 PCI_IOV_RESOURCES, 86 PCI_IOV_RESOURCES,
89 PCI_IOV_RESOURCE_END = PCI_IOV_RESOURCES + PCI_SRIOV_NUM_BARS - 1, 87 PCI_IOV_RESOURCE_END = PCI_IOV_RESOURCES + PCI_SRIOV_NUM_BARS - 1,
90#endif 88#endif
91 89
92 /* resources assigned to buses behind the bridge */ 90 /* Resources assigned to buses behind the bridge */
93#define PCI_BRIDGE_RESOURCE_NUM 4 91#define PCI_BRIDGE_RESOURCE_NUM 4
94 92
95 PCI_BRIDGE_RESOURCES, 93 PCI_BRIDGE_RESOURCES,
96 PCI_BRIDGE_RESOURCE_END = PCI_BRIDGE_RESOURCES + 94 PCI_BRIDGE_RESOURCE_END = PCI_BRIDGE_RESOURCES +
97 PCI_BRIDGE_RESOURCE_NUM - 1, 95 PCI_BRIDGE_RESOURCE_NUM - 1,
98 96
99 /* total resources associated with a PCI device */ 97 /* Total resources associated with a PCI device */
100 PCI_NUM_RESOURCES, 98 PCI_NUM_RESOURCES,
101 99
102 /* preserve this for compatibility */ 100 /* Preserve this for compatibility */
103 DEVICE_COUNT_RESOURCE = PCI_NUM_RESOURCES, 101 DEVICE_COUNT_RESOURCE = PCI_NUM_RESOURCES,
104}; 102};
105 103
@@ -152,9 +150,10 @@ static inline const char *pci_power_name(pci_power_t state)
152#define PCI_PM_D3COLD_WAIT 100 150#define PCI_PM_D3COLD_WAIT 100
153#define PCI_PM_BUS_WAIT 50 151#define PCI_PM_BUS_WAIT 50
154 152
155/** The pci_channel state describes connectivity between the CPU and 153/**
156 * the pci device. If some PCI bus between here and the pci device 154 * The pci_channel state describes connectivity between the CPU and
157 * has crashed or locked up, this info is reflected here. 155 * the PCI device. If some PCI bus between here and the PCI device
156 * has crashed or locked up, this info is reflected here.
158 */ 157 */
159typedef unsigned int __bitwise pci_channel_state_t; 158typedef unsigned int __bitwise pci_channel_state_t;
160 159
@@ -184,9 +183,7 @@ enum pcie_reset_state {
184 183
185typedef unsigned short __bitwise pci_dev_flags_t; 184typedef unsigned short __bitwise pci_dev_flags_t;
186enum pci_dev_flags { 185enum pci_dev_flags {
187 /* INTX_DISABLE in PCI_COMMAND register disables MSI 186 /* INTX_DISABLE in PCI_COMMAND register disables MSI too */
188 * generation too.
189 */
190 PCI_DEV_FLAGS_MSI_INTX_DISABLE_BUG = (__force pci_dev_flags_t) (1 << 0), 187 PCI_DEV_FLAGS_MSI_INTX_DISABLE_BUG = (__force pci_dev_flags_t) (1 << 0),
191 /* Device configuration is irrevocably lost if disabled into D3 */ 188 /* Device configuration is irrevocably lost if disabled into D3 */
192 PCI_DEV_FLAGS_NO_D3 = (__force pci_dev_flags_t) (1 << 1), 189 PCI_DEV_FLAGS_NO_D3 = (__force pci_dev_flags_t) (1 << 1),
@@ -202,7 +199,7 @@ enum pci_dev_flags {
202 PCI_DEV_FLAGS_NO_PM_RESET = (__force pci_dev_flags_t) (1 << 7), 199 PCI_DEV_FLAGS_NO_PM_RESET = (__force pci_dev_flags_t) (1 << 7),
203 /* Get VPD from function 0 VPD */ 200 /* Get VPD from function 0 VPD */
204 PCI_DEV_FLAGS_VPD_REF_F0 = (__force pci_dev_flags_t) (1 << 8), 201 PCI_DEV_FLAGS_VPD_REF_F0 = (__force pci_dev_flags_t) (1 << 8),
205 /* a non-root bridge where translation occurs, stop alias search here */ 202 /* A non-root bridge where translation occurs, stop alias search here */
206 PCI_DEV_FLAGS_BRIDGE_XLATE_ROOT = (__force pci_dev_flags_t) (1 << 9), 203 PCI_DEV_FLAGS_BRIDGE_XLATE_ROOT = (__force pci_dev_flags_t) (1 << 9),
207 /* Do not use FLR even if device advertises PCI_AF_CAP */ 204 /* Do not use FLR even if device advertises PCI_AF_CAP */
208 PCI_DEV_FLAGS_NO_FLR_RESET = (__force pci_dev_flags_t) (1 << 10), 205 PCI_DEV_FLAGS_NO_FLR_RESET = (__force pci_dev_flags_t) (1 << 10),
@@ -222,17 +219,17 @@ enum pci_bus_flags {
222 PCI_BUS_FLAGS_NO_AERSID = (__force pci_bus_flags_t) 4, 219 PCI_BUS_FLAGS_NO_AERSID = (__force pci_bus_flags_t) 4,
223}; 220};
224 221
225/* These values come from the PCI Express Spec */ 222/* Values from Link Status register, PCIe r3.1, sec 7.8.8 */
226enum pcie_link_width { 223enum pcie_link_width {
227 PCIE_LNK_WIDTH_RESRV = 0x00, 224 PCIE_LNK_WIDTH_RESRV = 0x00,
228 PCIE_LNK_X1 = 0x01, 225 PCIE_LNK_X1 = 0x01,
229 PCIE_LNK_X2 = 0x02, 226 PCIE_LNK_X2 = 0x02,
230 PCIE_LNK_X4 = 0x04, 227 PCIE_LNK_X4 = 0x04,
231 PCIE_LNK_X8 = 0x08, 228 PCIE_LNK_X8 = 0x08,
232 PCIE_LNK_X12 = 0x0C, 229 PCIE_LNK_X12 = 0x0c,
233 PCIE_LNK_X16 = 0x10, 230 PCIE_LNK_X16 = 0x10,
234 PCIE_LNK_X32 = 0x20, 231 PCIE_LNK_X32 = 0x20,
235 PCIE_LNK_WIDTH_UNKNOWN = 0xFF, 232 PCIE_LNK_WIDTH_UNKNOWN = 0xff,
236}; 233};
237 234
238/* Based on the PCI Hotplug Spec, but some values are made up by us */ 235/* Based on the PCI Hotplug Spec, but some values are made up by us */
@@ -263,15 +260,15 @@ enum pci_bus_speed {
263}; 260};
264 261
265struct pci_cap_saved_data { 262struct pci_cap_saved_data {
266 u16 cap_nr; 263 u16 cap_nr;
267 bool cap_extended; 264 bool cap_extended;
268 unsigned int size; 265 unsigned int size;
269 u32 data[0]; 266 u32 data[0];
270}; 267};
271 268
272struct pci_cap_saved_state { 269struct pci_cap_saved_state {
273 struct hlist_node next; 270 struct hlist_node next;
274 struct pci_cap_saved_data cap; 271 struct pci_cap_saved_data cap;
275}; 272};
276 273
277struct irq_affinity; 274struct irq_affinity;
@@ -280,19 +277,17 @@ struct pci_vpd;
280struct pci_sriov; 277struct pci_sriov;
281struct pci_ats; 278struct pci_ats;
282 279
283/* 280/* The pci_dev structure describes PCI devices */
284 * The pci_dev structure is used to describe PCI devices.
285 */
286struct pci_dev { 281struct pci_dev {
287 struct list_head bus_list; /* node in per-bus list */ 282 struct list_head bus_list; /* Node in per-bus list */
288 struct pci_bus *bus; /* bus this device is on */ 283 struct pci_bus *bus; /* Bus this device is on */
289 struct pci_bus *subordinate; /* bus this device bridges to */ 284 struct pci_bus *subordinate; /* Bus this device bridges to */
290 285
291 void *sysdata; /* hook for sys-specific extension */ 286 void *sysdata; /* Hook for sys-specific extension */
292 struct proc_dir_entry *procent; /* device entry in /proc/bus/pci */ 287 struct proc_dir_entry *procent; /* Device entry in /proc/bus/pci */
293 struct pci_slot *slot; /* Physical slot this device is in */ 288 struct pci_slot *slot; /* Physical slot this device is in */
294 289
295 unsigned int devfn; /* encoded device & function index */ 290 unsigned int devfn; /* Encoded device & function index */
296 unsigned short vendor; 291 unsigned short vendor;
297 unsigned short device; 292 unsigned short device;
298 unsigned short subsystem_vendor; 293 unsigned short subsystem_vendor;
@@ -307,12 +302,12 @@ struct pci_dev {
307 u8 msi_cap; /* MSI capability offset */ 302 u8 msi_cap; /* MSI capability offset */
308 u8 msix_cap; /* MSI-X capability offset */ 303 u8 msix_cap; /* MSI-X capability offset */
309 u8 pcie_mpss:3; /* PCIe Max Payload Size Supported */ 304 u8 pcie_mpss:3; /* PCIe Max Payload Size Supported */
310 u8 rom_base_reg; /* which config register controls the ROM */ 305 u8 rom_base_reg; /* Config register controlling ROM */
311 u8 pin; /* which interrupt pin this device uses */ 306 u8 pin; /* Interrupt pin this device uses */
312 u16 pcie_flags_reg; /* cached PCIe Capabilities Register */ 307 u16 pcie_flags_reg; /* Cached PCIe Capabilities Register */
313 unsigned long *dma_alias_mask;/* mask of enabled devfn aliases */ 308 unsigned long *dma_alias_mask;/* Mask of enabled devfn aliases */
314 309
315 struct pci_driver *driver; /* which driver has allocated this device */ 310 struct pci_driver *driver; /* Driver bound to this device */
316 u64 dma_mask; /* Mask of the bits of bus address this 311 u64 dma_mask; /* Mask of the bits of bus address this
317 device implements. Normally this is 312 device implements. Normally this is
318 0xffffffff. You only need to change 313 0xffffffff. You only need to change
@@ -321,9 +316,9 @@ struct pci_dev {
321 316
322 struct device_dma_parameters dma_parms; 317 struct device_dma_parameters dma_parms;
323 318
324 pci_power_t current_state; /* Current operating state. In ACPI-speak, 319 pci_power_t current_state; /* Current operating state. In ACPI,
325 this is D0-D3, D0 being fully functional, 320 this is D0-D3, D0 being fully
326 and D3 being off. */ 321 functional, and D3 being off. */
327 u8 pm_cap; /* PM capability offset */ 322 u8 pm_cap; /* PM capability offset */
328 unsigned int pme_support:5; /* Bitmask of states from which PME# 323 unsigned int pme_support:5; /* Bitmask of states from which PME#
329 can be generated */ 324 can be generated */
@@ -334,10 +329,10 @@ struct pci_dev {
334 unsigned int no_d3cold:1; /* D3cold is forbidden */ 329 unsigned int no_d3cold:1; /* D3cold is forbidden */
335 unsigned int bridge_d3:1; /* Allow D3 for bridge */ 330 unsigned int bridge_d3:1; /* Allow D3 for bridge */
336 unsigned int d3cold_allowed:1; /* D3cold is allowed by user */ 331 unsigned int d3cold_allowed:1; /* D3cold is allowed by user */
337 unsigned int mmio_always_on:1; /* disallow turning off io/mem 332 unsigned int mmio_always_on:1; /* Disallow turning off io/mem
338 decoding during bar sizing */ 333 decoding during BAR sizing */
339 unsigned int wakeup_prepared:1; 334 unsigned int wakeup_prepared:1;
340 unsigned int runtime_d3cold:1; /* whether go through runtime 335 unsigned int runtime_d3cold:1; /* Whether go through runtime
341 D3cold, not set for devices 336 D3cold, not set for devices
342 powered on/off by the 337 powered on/off by the
343 corresponding bridge */ 338 corresponding bridge */
@@ -350,12 +345,14 @@ struct pci_dev {
350 345
351#ifdef CONFIG_PCIEASPM 346#ifdef CONFIG_PCIEASPM
352 struct pcie_link_state *link_state; /* ASPM link state */ 347 struct pcie_link_state *link_state; /* ASPM link state */
348 unsigned int ltr_path:1; /* Latency Tolerance Reporting
349 supported from root to here */
353#endif 350#endif
354 351
355 pci_channel_state_t error_state; /* current connectivity state */ 352 pci_channel_state_t error_state; /* Current connectivity state */
356 struct device dev; /* Generic device interface */ 353 struct device dev; /* Generic device interface */
357 354
358 int cfg_size; /* Size of configuration space */ 355 int cfg_size; /* Size of config space */
359 356
360 /* 357 /*
361 * Instead of touching interrupt line and base address registers 358 * Instead of touching interrupt line and base address registers
@@ -364,47 +361,47 @@ struct pci_dev {
364 unsigned int irq; 361 unsigned int irq;
365 struct resource resource[DEVICE_COUNT_RESOURCE]; /* I/O and memory regions + expansion ROMs */ 362 struct resource resource[DEVICE_COUNT_RESOURCE]; /* I/O and memory regions + expansion ROMs */
366 363
367 bool match_driver; /* Skip attaching driver */ 364 bool match_driver; /* Skip attaching driver */
368 /* These fields are used by common fixups */ 365
369 unsigned int transparent:1; /* Subtractive decode PCI bridge */ 366 unsigned int transparent:1; /* Subtractive decode bridge */
370 unsigned int multifunction:1;/* Part of multi-function device */ 367 unsigned int multifunction:1; /* Multi-function device */
371 /* keep track of device state */ 368
372 unsigned int is_added:1; 369 unsigned int is_added:1;
373 unsigned int is_busmaster:1; /* device is busmaster */ 370 unsigned int is_busmaster:1; /* Is busmaster */
374 unsigned int no_msi:1; /* device may not use msi */ 371 unsigned int no_msi:1; /* May not use MSI */
375 unsigned int no_64bit_msi:1; /* device may only use 32-bit MSIs */ 372 unsigned int no_64bit_msi:1; /* May only use 32-bit MSIs */
376 unsigned int block_cfg_access:1; /* config space access is blocked */ 373 unsigned int block_cfg_access:1; /* Config space access blocked */
377 unsigned int broken_parity_status:1; /* Device generates false positive parity */ 374 unsigned int broken_parity_status:1; /* Generates false positive parity */
378 unsigned int irq_reroute_variant:2; /* device needs IRQ rerouting variant */ 375 unsigned int irq_reroute_variant:2; /* Needs IRQ rerouting variant */
379 unsigned int msi_enabled:1; 376 unsigned int msi_enabled:1;
380 unsigned int msix_enabled:1; 377 unsigned int msix_enabled:1;
381 unsigned int ari_enabled:1; /* ARI forwarding */ 378 unsigned int ari_enabled:1; /* ARI forwarding */
382 unsigned int ats_enabled:1; /* Address Translation Service */ 379 unsigned int ats_enabled:1; /* Address Translation Svc */
383 unsigned int pasid_enabled:1; /* Process Address Space ID */ 380 unsigned int pasid_enabled:1; /* Process Address Space ID */
384 unsigned int pri_enabled:1; /* Page Request Interface */ 381 unsigned int pri_enabled:1; /* Page Request Interface */
385 unsigned int is_managed:1; 382 unsigned int is_managed:1;
386 unsigned int needs_freset:1; /* Dev requires fundamental reset */ 383 unsigned int needs_freset:1; /* Requires fundamental reset */
387 unsigned int state_saved:1; 384 unsigned int state_saved:1;
388 unsigned int is_physfn:1; 385 unsigned int is_physfn:1;
389 unsigned int is_virtfn:1; 386 unsigned int is_virtfn:1;
390 unsigned int reset_fn:1; 387 unsigned int reset_fn:1;
391 unsigned int is_hotplug_bridge:1; 388 unsigned int is_hotplug_bridge:1;
392 unsigned int is_thunderbolt:1; /* Thunderbolt controller */ 389 unsigned int is_thunderbolt:1; /* Thunderbolt controller */
393 unsigned int __aer_firmware_first_valid:1; 390 unsigned int __aer_firmware_first_valid:1;
394 unsigned int __aer_firmware_first:1; 391 unsigned int __aer_firmware_first:1;
395 unsigned int broken_intx_masking:1; /* INTx masking can't be used */ 392 unsigned int broken_intx_masking:1; /* INTx masking can't be used */
396 unsigned int io_window_1k:1; /* Intel P2P bridge 1K I/O windows */ 393 unsigned int io_window_1k:1; /* Intel bridge 1K I/O windows */
397 unsigned int irq_managed:1; 394 unsigned int irq_managed:1;
398 unsigned int has_secondary_link:1; 395 unsigned int has_secondary_link:1;
399 unsigned int non_compliant_bars:1; /* broken BARs; ignore them */ 396 unsigned int non_compliant_bars:1; /* Broken BARs; ignore them */
400 unsigned int is_probed:1; /* device probing in progress */ 397 unsigned int is_probed:1; /* Device probing in progress */
401 pci_dev_flags_t dev_flags; 398 pci_dev_flags_t dev_flags;
402 atomic_t enable_cnt; /* pci_enable_device has been called */ 399 atomic_t enable_cnt; /* pci_enable_device has been called */
403 400
404 u32 saved_config_space[16]; /* config space saved at suspend time */ 401 u32 saved_config_space[16]; /* Config space saved at suspend time */
405 struct hlist_head saved_cap_space; 402 struct hlist_head saved_cap_space;
406 struct bin_attribute *rom_attr; /* attribute descriptor for sysfs ROM entry */ 403 struct bin_attribute *rom_attr; /* Attribute descriptor for sysfs ROM entry */
407 int rom_attr_enabled; /* has display of the rom attribute been enabled? */ 404 int rom_attr_enabled; /* Display of ROM attribute enabled? */
408 struct bin_attribute *res_attr[DEVICE_COUNT_RESOURCE]; /* sysfs file for resources */ 405 struct bin_attribute *res_attr[DEVICE_COUNT_RESOURCE]; /* sysfs file for resources */
409 struct bin_attribute *res_attr_wc[DEVICE_COUNT_RESOURCE]; /* sysfs file for WC mapping of resources */ 406 struct bin_attribute *res_attr_wc[DEVICE_COUNT_RESOURCE]; /* sysfs file for WC mapping of resources */
410 407
@@ -419,12 +416,12 @@ struct pci_dev {
419 struct pci_vpd *vpd; 416 struct pci_vpd *vpd;
420#ifdef CONFIG_PCI_ATS 417#ifdef CONFIG_PCI_ATS
421 union { 418 union {
422 struct pci_sriov *sriov; /* SR-IOV capability related */ 419 struct pci_sriov *sriov; /* PF: SR-IOV info */
423 struct pci_dev *physfn; /* the PF this VF is associated with */ 420 struct pci_dev *physfn; /* VF: related PF */
424 }; 421 };
425 u16 ats_cap; /* ATS Capability offset */ 422 u16 ats_cap; /* ATS Capability offset */
426 u8 ats_stu; /* ATS Smallest Translation Unit */ 423 u8 ats_stu; /* ATS Smallest Translation Unit */
427 atomic_t ats_ref_cnt; /* number of VFs with ATS enabled */ 424 atomic_t ats_ref_cnt; /* Number of VFs with ATS enabled */
428#endif 425#endif
429#ifdef CONFIG_PCI_PRI 426#ifdef CONFIG_PCI_PRI
430 u32 pri_reqs_alloc; /* Number of PRI requests allocated */ 427 u32 pri_reqs_alloc; /* Number of PRI requests allocated */
@@ -432,11 +429,11 @@ struct pci_dev {
432#ifdef CONFIG_PCI_PASID 429#ifdef CONFIG_PCI_PASID
433 u16 pasid_features; 430 u16 pasid_features;
434#endif 431#endif
435 phys_addr_t rom; /* Physical address of ROM if it's not from the BAR */ 432 phys_addr_t rom; /* Physical address if not from BAR */
436 size_t romlen; /* Length of ROM if it's not from the BAR */ 433 size_t romlen; /* Length if not from BAR */
437 char *driver_override; /* Driver name to force a match */ 434 char *driver_override; /* Driver name to force a match */
438 435
439 unsigned long priv_flags; /* Private flags for the pci driver */ 436 unsigned long priv_flags; /* Private flags for the PCI driver */
440}; 437};
441 438
442static inline struct pci_dev *pci_physfn(struct pci_dev *dev) 439static inline struct pci_dev *pci_physfn(struct pci_dev *dev)
@@ -459,26 +456,26 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
459} 456}
460 457
461struct pci_host_bridge { 458struct pci_host_bridge {
462 struct device dev; 459 struct device dev;
463 struct pci_bus *bus; /* root bus */ 460 struct pci_bus *bus; /* Root bus */
464 struct pci_ops *ops; 461 struct pci_ops *ops;
465 void *sysdata; 462 void *sysdata;
466 int busnr; 463 int busnr;
467 struct list_head windows; /* resource_entry */ 464 struct list_head windows; /* resource_entry */
468 u8 (*swizzle_irq)(struct pci_dev *, u8 *); /* platform IRQ swizzler */ 465 u8 (*swizzle_irq)(struct pci_dev *, u8 *); /* Platform IRQ swizzler */
469 int (*map_irq)(const struct pci_dev *, u8, u8); 466 int (*map_irq)(const struct pci_dev *, u8, u8);
470 void (*release_fn)(struct pci_host_bridge *); 467 void (*release_fn)(struct pci_host_bridge *);
471 void *release_data; 468 void *release_data;
472 struct msi_controller *msi; 469 struct msi_controller *msi;
473 unsigned int ignore_reset_delay:1; /* for entire hierarchy */ 470 unsigned int ignore_reset_delay:1; /* For entire hierarchy */
474 unsigned int no_ext_tags:1; /* no Extended Tags */ 471 unsigned int no_ext_tags:1; /* No Extended Tags */
475 /* Resource alignment requirements */ 472 /* Resource alignment requirements */
476 resource_size_t (*align_resource)(struct pci_dev *dev, 473 resource_size_t (*align_resource)(struct pci_dev *dev,
477 const struct resource *res, 474 const struct resource *res,
478 resource_size_t start, 475 resource_size_t start,
479 resource_size_t size, 476 resource_size_t size,
480 resource_size_t align); 477 resource_size_t align);
481 unsigned long private[0] ____cacheline_aligned; 478 unsigned long private[0] ____cacheline_aligned;
482}; 479};
483 480
484#define to_pci_host_bridge(n) container_of(n, struct pci_host_bridge, dev) 481#define to_pci_host_bridge(n) container_of(n, struct pci_host_bridge, dev)
@@ -500,8 +497,8 @@ void pci_free_host_bridge(struct pci_host_bridge *bridge);
500struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus); 497struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus);
501 498
502void pci_set_host_bridge_release(struct pci_host_bridge *bridge, 499void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
503 void (*release_fn)(struct pci_host_bridge *), 500 void (*release_fn)(struct pci_host_bridge *),
504 void *release_data); 501 void *release_data);
505 502
506int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge); 503int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge);
507 504
@@ -521,32 +518,32 @@ int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge);
521#define PCI_SUBTRACTIVE_DECODE 0x1 518#define PCI_SUBTRACTIVE_DECODE 0x1
522 519
523struct pci_bus_resource { 520struct pci_bus_resource {
524 struct list_head list; 521 struct list_head list;
525 struct resource *res; 522 struct resource *res;
526 unsigned int flags; 523 unsigned int flags;
527}; 524};
528 525
529#define PCI_REGION_FLAG_MASK 0x0fU /* These bits of resource flags tell us the PCI region flags */ 526#define PCI_REGION_FLAG_MASK 0x0fU /* These bits of resource flags tell us the PCI region flags */
530 527
531struct pci_bus { 528struct pci_bus {
532 struct list_head node; /* node in list of buses */ 529 struct list_head node; /* Node in list of buses */
533 struct pci_bus *parent; /* parent bus this bridge is on */ 530 struct pci_bus *parent; /* Parent bus this bridge is on */
534 struct list_head children; /* list of child buses */ 531 struct list_head children; /* List of child buses */
535 struct list_head devices; /* list of devices on this bus */ 532 struct list_head devices; /* List of devices on this bus */
536 struct pci_dev *self; /* bridge device as seen by parent */ 533 struct pci_dev *self; /* Bridge device as seen by parent */
537 struct list_head slots; /* list of slots on this bus; 534 struct list_head slots; /* List of slots on this bus;
538 protected by pci_slot_mutex */ 535 protected by pci_slot_mutex */
539 struct resource *resource[PCI_BRIDGE_RESOURCE_NUM]; 536 struct resource *resource[PCI_BRIDGE_RESOURCE_NUM];
540 struct list_head resources; /* address space routed to this bus */ 537 struct list_head resources; /* Address space routed to this bus */
541 struct resource busn_res; /* bus numbers routed to this bus */ 538 struct resource busn_res; /* Bus numbers routed to this bus */
542 539
543 struct pci_ops *ops; /* configuration access functions */ 540 struct pci_ops *ops; /* Configuration access functions */
544 struct msi_controller *msi; /* MSI controller */ 541 struct msi_controller *msi; /* MSI controller */
545 void *sysdata; /* hook for sys-specific extension */ 542 void *sysdata; /* Hook for sys-specific extension */
546 struct proc_dir_entry *procdir; /* directory entry in /proc/bus/pci */ 543 struct proc_dir_entry *procdir; /* Directory entry in /proc/bus/pci */
547 544
548 unsigned char number; /* bus number */ 545 unsigned char number; /* Bus number */
549 unsigned char primary; /* number of primary bridge */ 546 unsigned char primary; /* Number of primary bridge */
550 unsigned char max_bus_speed; /* enum pci_bus_speed */ 547 unsigned char max_bus_speed; /* enum pci_bus_speed */
551 unsigned char cur_bus_speed; /* enum pci_bus_speed */ 548 unsigned char cur_bus_speed; /* enum pci_bus_speed */
552#ifdef CONFIG_PCI_DOMAINS_GENERIC 549#ifdef CONFIG_PCI_DOMAINS_GENERIC
@@ -555,12 +552,12 @@ struct pci_bus {
555 552
556 char name[48]; 553 char name[48];
557 554
558 unsigned short bridge_ctl; /* manage NO_ISA/FBB/et al behaviors */ 555 unsigned short bridge_ctl; /* Manage NO_ISA/FBB/et al behaviors */
559 pci_bus_flags_t bus_flags; /* inherited by child buses */ 556 pci_bus_flags_t bus_flags; /* Inherited by child buses */
560 struct device *bridge; 557 struct device *bridge;
561 struct device dev; 558 struct device dev;
562 struct bin_attribute *legacy_io; /* legacy I/O for this bus */ 559 struct bin_attribute *legacy_io; /* Legacy I/O for this bus */
563 struct bin_attribute *legacy_mem; /* legacy mem */ 560 struct bin_attribute *legacy_mem; /* Legacy mem */
564 unsigned int is_added:1; 561 unsigned int is_added:1;
565}; 562};
566 563
@@ -617,9 +614,7 @@ static inline bool pci_dev_msi_enabled(struct pci_dev *pci_dev)
617static inline bool pci_dev_msi_enabled(struct pci_dev *pci_dev) { return false; } 614static inline bool pci_dev_msi_enabled(struct pci_dev *pci_dev) { return false; }
618#endif 615#endif
619 616
620/* 617/* Error values that may be returned by PCI functions */
621 * Error values that may be returned by PCI functions.
622 */
623#define PCIBIOS_SUCCESSFUL 0x00 618#define PCIBIOS_SUCCESSFUL 0x00
624#define PCIBIOS_FUNC_NOT_SUPPORTED 0x81 619#define PCIBIOS_FUNC_NOT_SUPPORTED 0x81
625#define PCIBIOS_BAD_VENDOR_ID 0x83 620#define PCIBIOS_BAD_VENDOR_ID 0x83
@@ -628,9 +623,7 @@ static inline bool pci_dev_msi_enabled(struct pci_dev *pci_dev) { return false;
628#define PCIBIOS_SET_FAILED 0x88 623#define PCIBIOS_SET_FAILED 0x88
629#define PCIBIOS_BUFFER_TOO_SMALL 0x89 624#define PCIBIOS_BUFFER_TOO_SMALL 0x89
630 625
631/* 626/* Translate above to generic errno for passing back through non-PCI code */
632 * Translate above to generic errno for passing back through non-PCI code.
633 */
634static inline int pcibios_err_to_errno(int err) 627static inline int pcibios_err_to_errno(int err)
635{ 628{
636 if (err <= PCIBIOS_SUCCESSFUL) 629 if (err <= PCIBIOS_SUCCESSFUL)
@@ -680,13 +673,13 @@ typedef u32 pci_bus_addr_t;
680#endif 673#endif
681 674
682struct pci_bus_region { 675struct pci_bus_region {
683 pci_bus_addr_t start; 676 pci_bus_addr_t start;
684 pci_bus_addr_t end; 677 pci_bus_addr_t end;
685}; 678};
686 679
687struct pci_dynids { 680struct pci_dynids {
688 spinlock_t lock; /* protects list, index */ 681 spinlock_t lock; /* Protects list, index */
689 struct list_head list; /* for IDs added at runtime */ 682 struct list_head list; /* For IDs added at runtime */
690}; 683};
691 684
692 685
@@ -700,13 +693,13 @@ struct pci_dynids {
700typedef unsigned int __bitwise pci_ers_result_t; 693typedef unsigned int __bitwise pci_ers_result_t;
701 694
702enum pci_ers_result { 695enum pci_ers_result {
703 /* no result/none/not supported in device driver */ 696 /* No result/none/not supported in device driver */
704 PCI_ERS_RESULT_NONE = (__force pci_ers_result_t) 1, 697 PCI_ERS_RESULT_NONE = (__force pci_ers_result_t) 1,
705 698
706 /* Device driver can recover without slot reset */ 699 /* Device driver can recover without slot reset */
707 PCI_ERS_RESULT_CAN_RECOVER = (__force pci_ers_result_t) 2, 700 PCI_ERS_RESULT_CAN_RECOVER = (__force pci_ers_result_t) 2,
708 701
709 /* Device driver wants slot to be reset. */ 702 /* Device driver wants slot to be reset */
710 PCI_ERS_RESULT_NEED_RESET = (__force pci_ers_result_t) 3, 703 PCI_ERS_RESULT_NEED_RESET = (__force pci_ers_result_t) 3,
711 704
712 /* Device has completely failed, is unrecoverable */ 705 /* Device has completely failed, is unrecoverable */
@@ -742,27 +735,27 @@ struct pci_error_handlers {
742 735
743struct module; 736struct module;
744struct pci_driver { 737struct pci_driver {
745 struct list_head node; 738 struct list_head node;
746 const char *name; 739 const char *name;
747 const struct pci_device_id *id_table; /* must be non-NULL for probe to be called */ 740 const struct pci_device_id *id_table; /* Must be non-NULL for probe to be called */
748 int (*probe) (struct pci_dev *dev, const struct pci_device_id *id); /* New device inserted */ 741 int (*probe)(struct pci_dev *dev, const struct pci_device_id *id); /* New device inserted */
749 void (*remove) (struct pci_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */ 742 void (*remove)(struct pci_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */
750 int (*suspend) (struct pci_dev *dev, pm_message_t state); /* Device suspended */ 743 int (*suspend)(struct pci_dev *dev, pm_message_t state); /* Device suspended */
751 int (*suspend_late) (struct pci_dev *dev, pm_message_t state); 744 int (*suspend_late)(struct pci_dev *dev, pm_message_t state);
752 int (*resume_early) (struct pci_dev *dev); 745 int (*resume_early)(struct pci_dev *dev);
753 int (*resume) (struct pci_dev *dev); /* Device woken up */ 746 int (*resume) (struct pci_dev *dev); /* Device woken up */
754 void (*shutdown) (struct pci_dev *dev); 747 void (*shutdown) (struct pci_dev *dev);
755 int (*sriov_configure) (struct pci_dev *dev, int num_vfs); /* PF pdev */ 748 int (*sriov_configure) (struct pci_dev *dev, int num_vfs); /* On PF */
756 const struct pci_error_handlers *err_handler; 749 const struct pci_error_handlers *err_handler;
757 const struct attribute_group **groups; 750 const struct attribute_group **groups;
758 struct device_driver driver; 751 struct device_driver driver;
759 struct pci_dynids dynids; 752 struct pci_dynids dynids;
760}; 753};
761 754
762#define to_pci_driver(drv) container_of(drv, struct pci_driver, driver) 755#define to_pci_driver(drv) container_of(drv, struct pci_driver, driver)
763 756
764/** 757/**
765 * PCI_DEVICE - macro used to describe a specific pci device 758 * PCI_DEVICE - macro used to describe a specific PCI device
766 * @vend: the 16 bit PCI Vendor ID 759 * @vend: the 16 bit PCI Vendor ID
767 * @dev: the 16 bit PCI Device ID 760 * @dev: the 16 bit PCI Device ID
768 * 761 *
@@ -775,7 +768,7 @@ struct pci_driver {
775 .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID 768 .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID
776 769
777/** 770/**
778 * PCI_DEVICE_SUB - macro used to describe a specific pci device with subsystem 771 * PCI_DEVICE_SUB - macro used to describe a specific PCI device with subsystem
779 * @vend: the 16 bit PCI Vendor ID 772 * @vend: the 16 bit PCI Vendor ID
780 * @dev: the 16 bit PCI Device ID 773 * @dev: the 16 bit PCI Device ID
781 * @subvend: the 16 bit PCI Subvendor ID 774 * @subvend: the 16 bit PCI Subvendor ID
@@ -789,7 +782,7 @@ struct pci_driver {
789 .subvendor = (subvend), .subdevice = (subdev) 782 .subvendor = (subvend), .subdevice = (subdev)
790 783
791/** 784/**
792 * PCI_DEVICE_CLASS - macro used to describe a specific pci device class 785 * PCI_DEVICE_CLASS - macro used to describe a specific PCI device class
793 * @dev_class: the class, subclass, prog-if triple for this device 786 * @dev_class: the class, subclass, prog-if triple for this device
794 * @dev_class_mask: the class mask for this device 787 * @dev_class_mask: the class mask for this device
795 * 788 *
@@ -803,7 +796,7 @@ struct pci_driver {
803 .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID 796 .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID
804 797
805/** 798/**
806 * PCI_VDEVICE - macro used to describe a specific pci device in short form 799 * PCI_VDEVICE - macro used to describe a specific PCI device in short form
807 * @vend: the vendor name 800 * @vend: the vendor name
808 * @dev: the 16 bit PCI Device ID 801 * @dev: the 16 bit PCI Device ID
809 * 802 *
@@ -812,22 +805,21 @@ struct pci_driver {
812 * to PCI_ANY_ID. The macro allows the next field to follow as the device 805 * to PCI_ANY_ID. The macro allows the next field to follow as the device
813 * private data. 806 * private data.
814 */ 807 */
815
816#define PCI_VDEVICE(vend, dev) \ 808#define PCI_VDEVICE(vend, dev) \
817 .vendor = PCI_VENDOR_ID_##vend, .device = (dev), \ 809 .vendor = PCI_VENDOR_ID_##vend, .device = (dev), \
818 .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, 0, 0 810 .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, 0, 0
819 811
820enum { 812enum {
821 PCI_REASSIGN_ALL_RSRC = 0x00000001, /* ignore firmware setup */ 813 PCI_REASSIGN_ALL_RSRC = 0x00000001, /* Ignore firmware setup */
822 PCI_REASSIGN_ALL_BUS = 0x00000002, /* reassign all bus numbers */ 814 PCI_REASSIGN_ALL_BUS = 0x00000002, /* Reassign all bus numbers */
823 PCI_PROBE_ONLY = 0x00000004, /* use existing setup */ 815 PCI_PROBE_ONLY = 0x00000004, /* Use existing setup */
824 PCI_CAN_SKIP_ISA_ALIGN = 0x00000008, /* don't do ISA alignment */ 816 PCI_CAN_SKIP_ISA_ALIGN = 0x00000008, /* Don't do ISA alignment */
825 PCI_ENABLE_PROC_DOMAINS = 0x00000010, /* enable domains in /proc */ 817 PCI_ENABLE_PROC_DOMAINS = 0x00000010, /* Enable domains in /proc */
826 PCI_COMPAT_DOMAIN_0 = 0x00000020, /* ... except domain 0 */ 818 PCI_COMPAT_DOMAIN_0 = 0x00000020, /* ... except domain 0 */
827 PCI_SCAN_ALL_PCIE_DEVS = 0x00000040, /* scan all, not just dev 0 */ 819 PCI_SCAN_ALL_PCIE_DEVS = 0x00000040, /* Scan all, not just dev 0 */
828}; 820};
829 821
830/* these external functions are only available when PCI support is enabled */ 822/* These external functions are only available when PCI support is enabled */
831#ifdef CONFIG_PCI 823#ifdef CONFIG_PCI
832 824
833extern unsigned int pci_flags; 825extern unsigned int pci_flags;
@@ -840,11 +832,11 @@ static inline int pci_has_flag(int flag) { return pci_flags & flag; }
840void pcie_bus_configure_settings(struct pci_bus *bus); 832void pcie_bus_configure_settings(struct pci_bus *bus);
841 833
842enum pcie_bus_config_types { 834enum pcie_bus_config_types {
843 PCIE_BUS_TUNE_OFF, /* don't touch MPS at all */ 835 PCIE_BUS_TUNE_OFF, /* Don't touch MPS at all */
844 PCIE_BUS_DEFAULT, /* ensure MPS matches upstream bridge */ 836 PCIE_BUS_DEFAULT, /* Ensure MPS matches upstream bridge */
845 PCIE_BUS_SAFE, /* use largest MPS boot-time devices support */ 837 PCIE_BUS_SAFE, /* Use largest MPS boot-time devices support */
846 PCIE_BUS_PERFORMANCE, /* use MPS and MRRS for best performance */ 838 PCIE_BUS_PERFORMANCE, /* Use MPS and MRRS for best performance */
847 PCIE_BUS_PEER2PEER, /* set MPS = 128 for all devices */ 839 PCIE_BUS_PEER2PEER, /* Set MPS = 128 for all devices */
848}; 840};
849 841
850extern enum pcie_bus_config_types pcie_bus_config; 842extern enum pcie_bus_config_types pcie_bus_config;
@@ -853,7 +845,7 @@ extern struct bus_type pci_bus_type;
853 845
854/* Do NOT directly access these two variables, unless you are arch-specific PCI 846/* Do NOT directly access these two variables, unless you are arch-specific PCI
855 * code, or PCI core code. */ 847 * code, or PCI core code. */
856extern struct list_head pci_root_buses; /* list of all known PCI buses */ 848extern struct list_head pci_root_buses; /* List of all known PCI buses */
857/* Some device drivers need know if PCI is initiated */ 849/* Some device drivers need know if PCI is initiated */
858int no_pci_devices(void); 850int no_pci_devices(void);
859 851
@@ -887,12 +879,13 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata);
887struct pci_bus *pci_create_root_bus(struct device *parent, int bus, 879struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
888 struct pci_ops *ops, void *sysdata, 880 struct pci_ops *ops, void *sysdata,
889 struct list_head *resources); 881 struct list_head *resources);
882int pci_host_probe(struct pci_host_bridge *bridge);
890int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int busmax); 883int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int busmax);
891int pci_bus_update_busn_res_end(struct pci_bus *b, int busmax); 884int pci_bus_update_busn_res_end(struct pci_bus *b, int busmax);
892void pci_bus_release_busn_res(struct pci_bus *b); 885void pci_bus_release_busn_res(struct pci_bus *b);
893struct pci_bus *pci_scan_root_bus(struct device *parent, int bus, 886struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
894 struct pci_ops *ops, void *sysdata, 887 struct pci_ops *ops, void *sysdata,
895 struct list_head *resources); 888 struct list_head *resources);
896int pci_scan_root_bus_bridge(struct pci_host_bridge *bridge); 889int pci_scan_root_bus_bridge(struct pci_host_bridge *bridge);
897struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, 890struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
898 int busnr); 891 int busnr);
@@ -949,10 +942,10 @@ int pci_find_next_ht_capability(struct pci_dev *dev, int pos, int ht_cap);
949struct pci_bus *pci_find_next_bus(const struct pci_bus *from); 942struct pci_bus *pci_find_next_bus(const struct pci_bus *from);
950 943
951struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device, 944struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device,
952 struct pci_dev *from); 945 struct pci_dev *from);
953struct pci_dev *pci_get_subsys(unsigned int vendor, unsigned int device, 946struct pci_dev *pci_get_subsys(unsigned int vendor, unsigned int device,
954 unsigned int ss_vendor, unsigned int ss_device, 947 unsigned int ss_vendor, unsigned int ss_device,
955 struct pci_dev *from); 948 struct pci_dev *from);
956struct pci_dev *pci_get_slot(struct pci_bus *bus, unsigned int devfn); 949struct pci_dev *pci_get_slot(struct pci_bus *bus, unsigned int devfn);
957struct pci_dev *pci_get_domain_bus_and_slot(int domain, unsigned int bus, 950struct pci_dev *pci_get_domain_bus_and_slot(int domain, unsigned int bus,
958 unsigned int devfn); 951 unsigned int devfn);
@@ -1028,7 +1021,7 @@ static inline int pcie_capability_clear_dword(struct pci_dev *dev, int pos,
1028 return pcie_capability_clear_and_set_dword(dev, pos, clear, 0); 1021 return pcie_capability_clear_and_set_dword(dev, pos, clear, 0);
1029} 1022}
1030 1023
1031/* user-space driven config access */ 1024/* User-space driven config access */
1032int pci_user_read_config_byte(struct pci_dev *dev, int where, u8 *val); 1025int pci_user_read_config_byte(struct pci_dev *dev, int where, u8 *val);
1033int pci_user_read_config_word(struct pci_dev *dev, int where, u16 *val); 1026int pci_user_read_config_word(struct pci_dev *dev, int where, u16 *val);
1034int pci_user_read_config_dword(struct pci_dev *dev, int where, u32 *val); 1027int pci_user_read_config_dword(struct pci_dev *dev, int where, u32 *val);
@@ -1171,7 +1164,7 @@ unsigned int pci_rescan_bus(struct pci_bus *bus);
1171void pci_lock_rescan_remove(void); 1164void pci_lock_rescan_remove(void);
1172void pci_unlock_rescan_remove(void); 1165void pci_unlock_rescan_remove(void);
1173 1166
1174/* Vital product data routines */ 1167/* Vital Product Data routines */
1175ssize_t pci_read_vpd(struct pci_dev *dev, loff_t pos, size_t count, void *buf); 1168ssize_t pci_read_vpd(struct pci_dev *dev, loff_t pos, size_t count, void *buf);
1176ssize_t pci_write_vpd(struct pci_dev *dev, loff_t pos, size_t count, const void *buf); 1169ssize_t pci_write_vpd(struct pci_dev *dev, loff_t pos, size_t count, const void *buf);
1177int pci_set_vpd_size(struct pci_dev *dev, size_t len); 1170int pci_set_vpd_size(struct pci_dev *dev, size_t len);
@@ -1256,9 +1249,7 @@ static inline pci_bus_addr_t pci_bus_address(struct pci_dev *pdev, int bar)
1256int __must_check __pci_register_driver(struct pci_driver *, struct module *, 1249int __must_check __pci_register_driver(struct pci_driver *, struct module *,
1257 const char *mod_name); 1250 const char *mod_name);
1258 1251
1259/* 1252/* pci_register_driver() must be a macro so KBUILD_MODNAME can be expanded */
1260 * pci_register_driver must be a macro so that KBUILD_MODNAME can be expanded
1261 */
1262#define pci_register_driver(driver) \ 1253#define pci_register_driver(driver) \
1263 __pci_register_driver(driver, THIS_MODULE, KBUILD_MODNAME) 1254 __pci_register_driver(driver, THIS_MODULE, KBUILD_MODNAME)
1264 1255
@@ -1273,8 +1264,7 @@ void pci_unregister_driver(struct pci_driver *dev);
1273 * use this macro once, and calling it replaces module_init() and module_exit() 1264 * use this macro once, and calling it replaces module_init() and module_exit()
1274 */ 1265 */
1275#define module_pci_driver(__pci_driver) \ 1266#define module_pci_driver(__pci_driver) \
1276 module_driver(__pci_driver, pci_register_driver, \ 1267 module_driver(__pci_driver, pci_register_driver, pci_unregister_driver)
1277 pci_unregister_driver)
1278 1268
1279/** 1269/**
1280 * builtin_pci_driver() - Helper macro for registering a PCI driver 1270 * builtin_pci_driver() - Helper macro for registering a PCI driver
@@ -1313,10 +1303,10 @@ resource_size_t pcibios_iov_resource_alignment(struct pci_dev *dev, int resno);
1313int pci_set_vga_state(struct pci_dev *pdev, bool decode, 1303int pci_set_vga_state(struct pci_dev *pdev, bool decode,
1314 unsigned int command_bits, u32 flags); 1304 unsigned int command_bits, u32 flags);
1315 1305
1316#define PCI_IRQ_LEGACY (1 << 0) /* allow legacy interrupts */ 1306#define PCI_IRQ_LEGACY (1 << 0) /* Allow legacy interrupts */
1317#define PCI_IRQ_MSI (1 << 1) /* allow MSI interrupts */ 1307#define PCI_IRQ_MSI (1 << 1) /* Allow MSI interrupts */
1318#define PCI_IRQ_MSIX (1 << 2) /* allow MSI-X interrupts */ 1308#define PCI_IRQ_MSIX (1 << 2) /* Allow MSI-X interrupts */
1319#define PCI_IRQ_AFFINITY (1 << 3) /* auto-assign affinity */ 1309#define PCI_IRQ_AFFINITY (1 << 3) /* Auto-assign affinity */
1320#define PCI_IRQ_ALL_TYPES \ 1310#define PCI_IRQ_ALL_TYPES \
1321 (PCI_IRQ_LEGACY | PCI_IRQ_MSI | PCI_IRQ_MSIX) 1311 (PCI_IRQ_LEGACY | PCI_IRQ_MSI | PCI_IRQ_MSIX)
1322 1312
@@ -1335,8 +1325,8 @@ int pci_set_vga_state(struct pci_dev *pdev, bool decode,
1335#define pci_pool_free(pool, vaddr, addr) dma_pool_free(pool, vaddr, addr) 1325#define pci_pool_free(pool, vaddr, addr) dma_pool_free(pool, vaddr, addr)
1336 1326
1337struct msix_entry { 1327struct msix_entry {
1338 u32 vector; /* kernel uses to write allocated vector */ 1328 u32 vector; /* Kernel uses to write allocated vector */
1339 u16 entry; /* driver uses to specify entry, OS writes */ 1329 u16 entry; /* Driver uses to specify entry, OS writes */
1340}; 1330};
1341 1331
1342#ifdef CONFIG_PCI_MSI 1332#ifdef CONFIG_PCI_MSI
@@ -1376,10 +1366,10 @@ static inline int pci_msi_enabled(void) { return 0; }
1376static inline int pci_enable_msi(struct pci_dev *dev) 1366static inline int pci_enable_msi(struct pci_dev *dev)
1377{ return -ENOSYS; } 1367{ return -ENOSYS; }
1378static inline int pci_enable_msix_range(struct pci_dev *dev, 1368static inline int pci_enable_msix_range(struct pci_dev *dev,
1379 struct msix_entry *entries, int minvec, int maxvec) 1369 struct msix_entry *entries, int minvec, int maxvec)
1380{ return -ENOSYS; } 1370{ return -ENOSYS; }
1381static inline int pci_enable_msix_exact(struct pci_dev *dev, 1371static inline int pci_enable_msix_exact(struct pci_dev *dev,
1382 struct msix_entry *entries, int nvec) 1372 struct msix_entry *entries, int nvec)
1383{ return -ENOSYS; } 1373{ return -ENOSYS; }
1384 1374
1385static inline int 1375static inline int
@@ -1544,9 +1534,9 @@ static inline int acpi_pci_bus_find_domain_nr(struct pci_bus *bus)
1544int pci_bus_find_domain_nr(struct pci_bus *bus, struct device *parent); 1534int pci_bus_find_domain_nr(struct pci_bus *bus, struct device *parent);
1545#endif 1535#endif
1546 1536
1547/* some architectures require additional setup to direct VGA traffic */ 1537/* Some architectures require additional setup to direct VGA traffic */
1548typedef int (*arch_set_vga_state_t)(struct pci_dev *pdev, bool decode, 1538typedef int (*arch_set_vga_state_t)(struct pci_dev *pdev, bool decode,
1549 unsigned int command_bits, u32 flags); 1539 unsigned int command_bits, u32 flags);
1550void pci_register_set_vga_state(arch_set_vga_state_t func); 1540void pci_register_set_vga_state(arch_set_vga_state_t func);
1551 1541
1552static inline int 1542static inline int
@@ -1585,10 +1575,9 @@ static inline void pci_clear_flags(int flags) { }
1585static inline int pci_has_flag(int flag) { return 0; } 1575static inline int pci_has_flag(int flag) { return 0; }
1586 1576
1587/* 1577/*
1588 * If the system does not have PCI, clearly these return errors. Define 1578 * If the system does not have PCI, clearly these return errors. Define
1589 * these as simple inline functions to avoid hair in drivers. 1579 * these as simple inline functions to avoid hair in drivers.
1590 */ 1580 */
1591
1592#define _PCI_NOP(o, s, t) \ 1581#define _PCI_NOP(o, s, t) \
1593 static inline int pci_##o##_config_##s(struct pci_dev *dev, \ 1582 static inline int pci_##o##_config_##s(struct pci_dev *dev, \
1594 int where, t val) \ 1583 int where, t val) \
@@ -1687,6 +1676,13 @@ static inline int pci_get_new_domain_nr(void) { return -ENOSYS; }
1687#define dev_is_pf(d) (false) 1676#define dev_is_pf(d) (false)
1688static inline bool pci_acs_enabled(struct pci_dev *pdev, u16 acs_flags) 1677static inline bool pci_acs_enabled(struct pci_dev *pdev, u16 acs_flags)
1689{ return false; } 1678{ return false; }
1679static inline int pci_irqd_intx_xlate(struct irq_domain *d,
1680 struct device_node *node,
1681 const u32 *intspec,
1682 unsigned int intsize,
1683 unsigned long *out_hwirq,
1684 unsigned int *out_type)
1685{ return -EINVAL; }
1690#endif /* CONFIG_PCI */ 1686#endif /* CONFIG_PCI */
1691 1687
1692/* Include architecture-dependent settings and functions */ 1688/* Include architecture-dependent settings and functions */
@@ -1727,8 +1723,10 @@ int pci_iobar_pfn(struct pci_dev *pdev, int bar, struct vm_area_struct *vma);
1727#define pci_root_bus_fwnode(bus) NULL 1723#define pci_root_bus_fwnode(bus) NULL
1728#endif 1724#endif
1729 1725
1730/* these helpers provide future and backwards compatibility 1726/*
1731 * for accessing popular PCI BAR info */ 1727 * These helpers provide future and backwards compatibility
1728 * for accessing popular PCI BAR info
1729 */
1732#define pci_resource_start(dev, bar) ((dev)->resource[(bar)].start) 1730#define pci_resource_start(dev, bar) ((dev)->resource[(bar)].start)
1733#define pci_resource_end(dev, bar) ((dev)->resource[(bar)].end) 1731#define pci_resource_end(dev, bar) ((dev)->resource[(bar)].end)
1734#define pci_resource_flags(dev, bar) ((dev)->resource[(bar)].flags) 1732#define pci_resource_flags(dev, bar) ((dev)->resource[(bar)].flags)
@@ -1740,7 +1738,8 @@ int pci_iobar_pfn(struct pci_dev *pdev, int bar, struct vm_area_struct *vma);
1740 (pci_resource_end((dev), (bar)) - \ 1738 (pci_resource_end((dev), (bar)) - \
1741 pci_resource_start((dev), (bar)) + 1)) 1739 pci_resource_start((dev), (bar)) + 1))
1742 1740
1743/* Similar to the helpers above, these manipulate per-pci_dev 1741/*
1742 * Similar to the helpers above, these manipulate per-pci_dev
1744 * driver-specific data. They are really just a wrapper around 1743 * driver-specific data. They are really just a wrapper around
1745 * the generic device structure functions of these calls. 1744 * the generic device structure functions of these calls.
1746 */ 1745 */
@@ -1754,16 +1753,14 @@ static inline void pci_set_drvdata(struct pci_dev *pdev, void *data)
1754 dev_set_drvdata(&pdev->dev, data); 1753 dev_set_drvdata(&pdev->dev, data);
1755} 1754}
1756 1755
1757/* If you want to know what to call your pci_dev, ask this function.
1758 * Again, it's a wrapper around the generic device.
1759 */
1760static inline const char *pci_name(const struct pci_dev *pdev) 1756static inline const char *pci_name(const struct pci_dev *pdev)
1761{ 1757{
1762 return dev_name(&pdev->dev); 1758 return dev_name(&pdev->dev);
1763} 1759}
1764 1760
1765 1761
1766/* Some archs don't want to expose struct resource to userland as-is 1762/*
1763 * Some archs don't want to expose struct resource to userland as-is
1767 * in sysfs and /proc 1764 * in sysfs and /proc
1768 */ 1765 */
1769#ifdef HAVE_ARCH_PCI_RESOURCE_TO_USER 1766#ifdef HAVE_ARCH_PCI_RESOURCE_TO_USER
@@ -1782,16 +1779,16 @@ static inline void pci_resource_to_user(const struct pci_dev *dev, int bar,
1782 1779
1783 1780
1784/* 1781/*
1785 * The world is not perfect and supplies us with broken PCI devices. 1782 * The world is not perfect and supplies us with broken PCI devices.
1786 * For at least a part of these bugs we need a work-around, so both 1783 * For at least a part of these bugs we need a work-around, so both
1787 * generic (drivers/pci/quirks.c) and per-architecture code can define 1784 * generic (drivers/pci/quirks.c) and per-architecture code can define
1788 * fixup hooks to be called for particular buggy devices. 1785 * fixup hooks to be called for particular buggy devices.
1789 */ 1786 */
1790 1787
1791struct pci_fixup { 1788struct pci_fixup {
1792 u16 vendor; /* You can use PCI_ANY_ID here of course */ 1789 u16 vendor; /* Or PCI_ANY_ID */
1793 u16 device; /* You can use PCI_ANY_ID here of course */ 1790 u16 device; /* Or PCI_ANY_ID */
1794 u32 class; /* You can use PCI_ANY_ID here too */ 1791 u32 class; /* Or PCI_ANY_ID */
1795 unsigned int class_shift; /* should be 0, 8, 16 */ 1792 unsigned int class_shift; /* should be 0, 8, 16 */
1796 void (*hook)(struct pci_dev *dev); 1793 void (*hook)(struct pci_dev *dev);
1797}; 1794};
@@ -1833,23 +1830,19 @@ enum pci_fixup_pass {
1833#define DECLARE_PCI_FIXUP_CLASS_RESUME(vendor, device, class, \ 1830#define DECLARE_PCI_FIXUP_CLASS_RESUME(vendor, device, class, \
1834 class_shift, hook) \ 1831 class_shift, hook) \
1835 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume, \ 1832 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume, \
1836 resume##hook, vendor, device, class, \ 1833 resume##hook, vendor, device, class, class_shift, hook)
1837 class_shift, hook)
1838#define DECLARE_PCI_FIXUP_CLASS_RESUME_EARLY(vendor, device, class, \ 1834#define DECLARE_PCI_FIXUP_CLASS_RESUME_EARLY(vendor, device, class, \
1839 class_shift, hook) \ 1835 class_shift, hook) \
1840 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume_early, \ 1836 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume_early, \
1841 resume_early##hook, vendor, device, \ 1837 resume_early##hook, vendor, device, class, class_shift, hook)
1842 class, class_shift, hook)
1843#define DECLARE_PCI_FIXUP_CLASS_SUSPEND(vendor, device, class, \ 1838#define DECLARE_PCI_FIXUP_CLASS_SUSPEND(vendor, device, class, \
1844 class_shift, hook) \ 1839 class_shift, hook) \
1845 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_suspend, \ 1840 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_suspend, \
1846 suspend##hook, vendor, device, class, \ 1841 suspend##hook, vendor, device, class, class_shift, hook)
1847 class_shift, hook)
1848#define DECLARE_PCI_FIXUP_CLASS_SUSPEND_LATE(vendor, device, class, \ 1842#define DECLARE_PCI_FIXUP_CLASS_SUSPEND_LATE(vendor, device, class, \
1849 class_shift, hook) \ 1843 class_shift, hook) \
1850 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_suspend_late, \ 1844 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_suspend_late, \
1851 suspend_late##hook, vendor, device, \ 1845 suspend_late##hook, vendor, device, class, class_shift, hook)
1852 class, class_shift, hook)
1853 1846
1854#define DECLARE_PCI_FIXUP_EARLY(vendor, device, hook) \ 1847#define DECLARE_PCI_FIXUP_EARLY(vendor, device, hook) \
1855 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_early, \ 1848 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_early, \
@@ -1865,20 +1858,16 @@ enum pci_fixup_pass {
1865 hook, vendor, device, PCI_ANY_ID, 0, hook) 1858 hook, vendor, device, PCI_ANY_ID, 0, hook)
1866#define DECLARE_PCI_FIXUP_RESUME(vendor, device, hook) \ 1859#define DECLARE_PCI_FIXUP_RESUME(vendor, device, hook) \
1867 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume, \ 1860 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume, \
1868 resume##hook, vendor, device, \ 1861 resume##hook, vendor, device, PCI_ANY_ID, 0, hook)
1869 PCI_ANY_ID, 0, hook)
1870#define DECLARE_PCI_FIXUP_RESUME_EARLY(vendor, device, hook) \ 1862#define DECLARE_PCI_FIXUP_RESUME_EARLY(vendor, device, hook) \
1871 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume_early, \ 1863 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume_early, \
1872 resume_early##hook, vendor, device, \ 1864 resume_early##hook, vendor, device, PCI_ANY_ID, 0, hook)
1873 PCI_ANY_ID, 0, hook)
1874#define DECLARE_PCI_FIXUP_SUSPEND(vendor, device, hook) \ 1865#define DECLARE_PCI_FIXUP_SUSPEND(vendor, device, hook) \
1875 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_suspend, \ 1866 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_suspend, \
1876 suspend##hook, vendor, device, \ 1867 suspend##hook, vendor, device, PCI_ANY_ID, 0, hook)
1877 PCI_ANY_ID, 0, hook)
1878#define DECLARE_PCI_FIXUP_SUSPEND_LATE(vendor, device, hook) \ 1868#define DECLARE_PCI_FIXUP_SUSPEND_LATE(vendor, device, hook) \
1879 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_suspend_late, \ 1869 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_suspend_late, \
1880 suspend_late##hook, vendor, device, \ 1870 suspend_late##hook, vendor, device, PCI_ANY_ID, 0, hook)
1881 PCI_ANY_ID, 0, hook)
1882 1871
1883#ifdef CONFIG_PCI_QUIRKS 1872#ifdef CONFIG_PCI_QUIRKS
1884void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev); 1873void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev);
@@ -2064,6 +2053,7 @@ void pci_request_acs(void);
2064bool pci_acs_enabled(struct pci_dev *pdev, u16 acs_flags); 2053bool pci_acs_enabled(struct pci_dev *pdev, u16 acs_flags);
2065bool pci_acs_path_enabled(struct pci_dev *start, 2054bool pci_acs_path_enabled(struct pci_dev *start,
2066 struct pci_dev *end, u16 acs_flags); 2055 struct pci_dev *end, u16 acs_flags);
2056int pci_enable_atomic_ops_to_root(struct pci_dev *dev, u32 cap_mask);
2067 2057
2068#define PCI_VPD_LRDT 0x80 /* Large Resource Data Type */ 2058#define PCI_VPD_LRDT 0x80 /* Large Resource Data Type */
2069#define PCI_VPD_LRDT_ID(x) ((x) | PCI_VPD_LRDT) 2059#define PCI_VPD_LRDT_ID(x) ((x) | PCI_VPD_LRDT)
@@ -2115,7 +2105,7 @@ static inline u16 pci_vpd_lrdt_size(const u8 *lrdt)
2115 */ 2105 */
2116static inline u16 pci_vpd_lrdt_tag(const u8 *lrdt) 2106static inline u16 pci_vpd_lrdt_tag(const u8 *lrdt)
2117{ 2107{
2118 return (u16)(lrdt[0] & PCI_VPD_LRDT_TIN_MASK); 2108 return (u16)(lrdt[0] & PCI_VPD_LRDT_TIN_MASK);
2119} 2109}
2120 2110
2121/** 2111/**
@@ -2185,6 +2175,9 @@ void pci_release_of_node(struct pci_dev *dev);
2185void pci_set_bus_of_node(struct pci_bus *bus); 2175void pci_set_bus_of_node(struct pci_bus *bus);
2186void pci_release_bus_of_node(struct pci_bus *bus); 2176void pci_release_bus_of_node(struct pci_bus *bus);
2187struct irq_domain *pci_host_bridge_of_msi_domain(struct pci_bus *bus); 2177struct irq_domain *pci_host_bridge_of_msi_domain(struct pci_bus *bus);
2178int pci_parse_request_of_pci_ranges(struct device *dev,
2179 struct list_head *resources,
2180 struct resource **bus_range);
2188 2181
2189/* Arch may override this (weak) */ 2182/* Arch may override this (weak) */
2190struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus); 2183struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus);
@@ -2200,7 +2193,7 @@ static inline struct device_node *pci_bus_to_OF_node(struct pci_bus *bus)
2200 return bus ? bus->dev.of_node : NULL; 2193 return bus ? bus->dev.of_node : NULL;
2201} 2194}
2202 2195
2203#else /* CONFIG_OF */ 2196#else /* CONFIG_OF */
2204static inline void pci_set_of_node(struct pci_dev *dev) { } 2197static inline void pci_set_of_node(struct pci_dev *dev) { }
2205static inline void pci_release_of_node(struct pci_dev *dev) { } 2198static inline void pci_release_of_node(struct pci_dev *dev) { }
2206static inline void pci_set_bus_of_node(struct pci_bus *bus) { } 2199static inline void pci_set_bus_of_node(struct pci_bus *bus) { }
@@ -2209,6 +2202,12 @@ static inline struct device_node *
2209pci_device_to_OF_node(const struct pci_dev *pdev) { return NULL; } 2202pci_device_to_OF_node(const struct pci_dev *pdev) { return NULL; }
2210static inline struct irq_domain * 2203static inline struct irq_domain *
2211pci_host_bridge_of_msi_domain(struct pci_bus *bus) { return NULL; } 2204pci_host_bridge_of_msi_domain(struct pci_bus *bus) { return NULL; }
2205static inline int pci_parse_request_of_pci_ranges(struct device *dev,
2206 struct list_head *resources,
2207 struct resource **bus_range)
2208{
2209 return -EINVAL;
2210}
2212#endif /* CONFIG_OF */ 2211#endif /* CONFIG_OF */
2213 2212
2214#ifdef CONFIG_ACPI 2213#ifdef CONFIG_ACPI
@@ -2234,7 +2233,7 @@ int pci_for_each_dma_alias(struct pci_dev *pdev,
2234 int (*fn)(struct pci_dev *pdev, 2233 int (*fn)(struct pci_dev *pdev,
2235 u16 alias, void *data), void *data); 2234 u16 alias, void *data), void *data);
2236 2235
2237/* helper functions for operation of device flag */ 2236/* Helper functions for operation of device flag */
2238static inline void pci_set_dev_assigned(struct pci_dev *pdev) 2237static inline void pci_set_dev_assigned(struct pci_dev *pdev)
2239{ 2238{
2240 pdev->dev_flags |= PCI_DEV_FLAGS_ASSIGNED; 2239 pdev->dev_flags |= PCI_DEV_FLAGS_ASSIGNED;
@@ -2317,7 +2316,19 @@ static inline void pci_uevent_ers(struct pci_dev *pdev,
2317 } 2316 }
2318} 2317}
2319 2318
2320/* provide the legacy pci_dma_* API */ 2319/* Provide the legacy pci_dma_* API */
2321#include <linux/pci-dma-compat.h> 2320#include <linux/pci-dma-compat.h>
2322 2321
2322#define pci_printk(level, pdev, fmt, arg...) \
2323 dev_printk(level, &(pdev)->dev, fmt, ##arg)
2324
2325#define pci_emerg(pdev, fmt, arg...) dev_emerg(&(pdev)->dev, fmt, ##arg)
2326#define pci_alert(pdev, fmt, arg...) dev_alert(&(pdev)->dev, fmt, ##arg)
2327#define pci_crit(pdev, fmt, arg...) dev_crit(&(pdev)->dev, fmt, ##arg)
2328#define pci_err(pdev, fmt, arg...) dev_err(&(pdev)->dev, fmt, ##arg)
2329#define pci_warn(pdev, fmt, arg...) dev_warn(&(pdev)->dev, fmt, ##arg)
2330#define pci_notice(pdev, fmt, arg...) dev_notice(&(pdev)->dev, fmt, ##arg)
2331#define pci_info(pdev, fmt, arg...) dev_info(&(pdev)->dev, fmt, ##arg)
2332#define pci_dbg(pdev, fmt, arg...) dev_dbg(&(pdev)->dev, fmt, ##arg)
2333
2323#endif /* LINUX_PCI_H */ 2334#endif /* LINUX_PCI_H */
diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
index 2e855afa0212..26213024e81b 100644
--- a/include/linux/pci_hotplug.h
+++ b/include/linux/pci_hotplug.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0+ */
1/* 2/*
2 * PCI HotPlug Core Functions 3 * PCI HotPlug Core Functions
3 * 4 *
@@ -7,21 +8,6 @@
7 * 8 *
8 * All rights reserved. 9 * All rights reserved.
9 * 10 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or (at
13 * your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
18 * NON INFRINGEMENT. See the GNU General Public License for more
19 * details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 *
25 * Send feedback to <kristen.c.accardi@intel.com> 11 * Send feedback to <kristen.c.accardi@intel.com>
26 * 12 *
27 */ 13 */
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index ab20dc5db423..eb13e84e1fef 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -2381,6 +2381,8 @@
2381 2381
2382#define PCI_VENDOR_ID_LENOVO 0x17aa 2382#define PCI_VENDOR_ID_LENOVO 0x17aa
2383 2383
2384#define PCI_VENDOR_ID_CDNS 0x17cd
2385
2384#define PCI_VENDOR_ID_ARECA 0x17d3 2386#define PCI_VENDOR_ID_ARECA 0x17d3
2385#define PCI_DEVICE_ID_ARECA_1110 0x1110 2387#define PCI_DEVICE_ID_ARECA_1110 0x1110
2386#define PCI_DEVICE_ID_ARECA_1120 0x1120 2388#define PCI_DEVICE_ID_ARECA_1120 0x1120
diff --git a/include/linux/pfn_t.h b/include/linux/pfn_t.h
index 43b1d7648e82..a03c2642a87c 100644
--- a/include/linux/pfn_t.h
+++ b/include/linux/pfn_t.h
@@ -15,8 +15,10 @@
15#define PFN_SG_LAST (1ULL << (BITS_PER_LONG_LONG - 2)) 15#define PFN_SG_LAST (1ULL << (BITS_PER_LONG_LONG - 2))
16#define PFN_DEV (1ULL << (BITS_PER_LONG_LONG - 3)) 16#define PFN_DEV (1ULL << (BITS_PER_LONG_LONG - 3))
17#define PFN_MAP (1ULL << (BITS_PER_LONG_LONG - 4)) 17#define PFN_MAP (1ULL << (BITS_PER_LONG_LONG - 4))
18#define PFN_SPECIAL (1ULL << (BITS_PER_LONG_LONG - 5))
18 19
19#define PFN_FLAGS_TRACE \ 20#define PFN_FLAGS_TRACE \
21 { PFN_SPECIAL, "SPECIAL" }, \
20 { PFN_SG_CHAIN, "SG_CHAIN" }, \ 22 { PFN_SG_CHAIN, "SG_CHAIN" }, \
21 { PFN_SG_LAST, "SG_LAST" }, \ 23 { PFN_SG_LAST, "SG_LAST" }, \
22 { PFN_DEV, "DEV" }, \ 24 { PFN_DEV, "DEV" }, \
@@ -120,4 +122,15 @@ pud_t pud_mkdevmap(pud_t pud);
120#endif 122#endif
121#endif /* __HAVE_ARCH_PTE_DEVMAP */ 123#endif /* __HAVE_ARCH_PTE_DEVMAP */
122 124
125#ifdef __HAVE_ARCH_PTE_SPECIAL
126static inline bool pfn_t_special(pfn_t pfn)
127{
128 return (pfn.val & PFN_SPECIAL) == PFN_SPECIAL;
129}
130#else
131static inline bool pfn_t_special(pfn_t pfn)
132{
133 return false;
134}
135#endif /* __HAVE_ARCH_PTE_SPECIAL */
123#endif /* _LINUX_PFN_T_H_ */ 136#endif /* _LINUX_PFN_T_H_ */
diff --git a/include/linux/platform_data/mlxcpld-hotplug.h b/include/linux/platform_data/mlxcpld-hotplug.h
deleted file mode 100644
index e4cfcffaa6f4..000000000000
--- a/include/linux/platform_data/mlxcpld-hotplug.h
+++ /dev/null
@@ -1,99 +0,0 @@
1/*
2 * include/linux/platform_data/mlxcpld-hotplug.h
3 * Copyright (c) 2016 Mellanox Technologies. All rights reserved.
4 * Copyright (c) 2016 Vadim Pasternak <vadimp@mellanox.com>
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the names of the copyright holders nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * Alternatively, this software may be distributed under the terms of the
19 * GNU General Public License ("GPL") version 2 as published by the Free
20 * Software Foundation.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 */
34
35#ifndef __LINUX_PLATFORM_DATA_MLXCPLD_HOTPLUG_H
36#define __LINUX_PLATFORM_DATA_MLXCPLD_HOTPLUG_H
37
38/**
39 * struct mlxcpld_hotplug_device - I2C device data:
40 * @adapter: I2C device adapter;
41 * @client: I2C device client;
42 * @brdinfo: device board information;
43 * @bus: I2C bus, where device is attached;
44 *
45 * Structure represents I2C hotplug device static data (board topology) and
46 * dynamic data (related kernel objects handles).
47 */
48struct mlxcpld_hotplug_device {
49 struct i2c_adapter *adapter;
50 struct i2c_client *client;
51 struct i2c_board_info brdinfo;
52 u16 bus;
53};
54
55/**
56 * struct mlxcpld_hotplug_platform_data - device platform data:
57 * @top_aggr_offset: offset of top aggregation interrupt register;
58 * @top_aggr_mask: top aggregation interrupt common mask;
59 * @top_aggr_psu_mask: top aggregation interrupt PSU mask;
60 * @psu_reg_offset: offset of PSU interrupt register;
61 * @psu_mask: PSU interrupt mask;
62 * @psu_count: number of equipped replaceable PSUs;
63 * @psu: pointer to PSU devices data array;
64 * @top_aggr_pwr_mask: top aggregation interrupt power mask;
65 * @pwr_reg_offset: offset of power interrupt register
66 * @pwr_mask: power interrupt mask;
67 * @pwr_count: number of power sources;
68 * @pwr: pointer to power devices data array;
69 * @top_aggr_fan_mask: top aggregation interrupt FAN mask;
70 * @fan_reg_offset: offset of FAN interrupt register;
71 * @fan_mask: FAN interrupt mask;
72 * @fan_count: number of equipped replaceable FANs;
73 * @fan: pointer to FAN devices data array;
74 *
75 * Structure represents board platform data, related to system hotplug events,
76 * like FAN, PSU, power cable insertion and removing. This data provides the
77 * number of hot-pluggable devices and hardware description for event handling.
78 */
79struct mlxcpld_hotplug_platform_data {
80 u16 top_aggr_offset;
81 u8 top_aggr_mask;
82 u8 top_aggr_psu_mask;
83 u16 psu_reg_offset;
84 u8 psu_mask;
85 u8 psu_count;
86 struct mlxcpld_hotplug_device *psu;
87 u8 top_aggr_pwr_mask;
88 u16 pwr_reg_offset;
89 u8 pwr_mask;
90 u8 pwr_count;
91 struct mlxcpld_hotplug_device *pwr;
92 u8 top_aggr_fan_mask;
93 u16 fan_reg_offset;
94 u8 fan_mask;
95 u8 fan_count;
96 struct mlxcpld_hotplug_device *fan;
97};
98
99#endif /* __LINUX_PLATFORM_DATA_MLXCPLD_HOTPLUG_H */
diff --git a/include/linux/platform_data/mlxreg.h b/include/linux/platform_data/mlxreg.h
new file mode 100644
index 000000000000..fcdc707eab99
--- /dev/null
+++ b/include/linux/platform_data/mlxreg.h
@@ -0,0 +1,144 @@
1/*
2 * Copyright (c) 2017 Mellanox Technologies. All rights reserved.
3 * Copyright (c) 2017 Vadim Pasternak <vadimp@mellanox.com>
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the names of the copyright holders nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
16 *
17 * Alternatively, this software may be distributed under the terms of the
18 * GNU General Public License ("GPL") version 2 as published by the Free
19 * Software Foundation.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 */
33
34#ifndef __LINUX_PLATFORM_DATA_MLXREG_H
35#define __LINUX_PLATFORM_DATA_MLXREG_H
36
37#define MLXREG_CORE_LABEL_MAX_SIZE 32
38
39/**
40 * struct mlxreg_hotplug_device - I2C device data:
41 *
42 * @adapter: I2C device adapter;
43 * @client: I2C device client;
44 * @brdinfo: device board information;
45 * @nr: I2C device adapter number, to which device is to be attached;
46 *
47 * Structure represents I2C hotplug device static data (board topology) and
48 * dynamic data (related kernel objects handles).
49 */
50struct mlxreg_hotplug_device {
51 struct i2c_adapter *adapter;
52 struct i2c_client *client;
53 struct i2c_board_info *brdinfo;
54 int nr;
55};
56
57/**
58 * struct mlxreg_core_data - attributes control data:
59 *
60 * @label: attribute label;
61 * @label: attribute register offset;
62 * @reg: attribute register;
63 * @mask: attribute access mask;
64 * @mode: access mode;
65 * @bit: attribute effective bit;
66 * @np - pointer to node platform associated with attribute;
67 * @hpdev - hotplug device data;
68 * @health_cntr: dynamic device health indication counter;
69 * @attached: true if device has been attached after good health indication;
70 */
71struct mlxreg_core_data {
72 char label[MLXREG_CORE_LABEL_MAX_SIZE];
73 u32 reg;
74 u32 mask;
75 u32 bit;
76 umode_t mode;
77 struct device_node *np;
78 struct mlxreg_hotplug_device hpdev;
79 u8 health_cntr;
80 bool attached;
81};
82
83/**
84 * struct mlxreg_core_item - same type components controlled by the driver:
85 *
86 * @data: component data;
87 * @aggr_mask: group aggregation mask;
88 * @reg: group interrupt status register;
89 * @mask: group interrupt mask;
90 * @cache: last status value for elements fro the same group;
91 * @count: number of available elements in the group;
92 * @ind: element's index inside the group;
93 * @inversed: if 0: 0 for signal status is OK, if 1 - 1 is OK;
94 * @health: true if device has health indication, false in other case;
95 */
96struct mlxreg_core_item {
97 struct mlxreg_core_data *data;
98 u32 aggr_mask;
99 u32 reg;
100 u32 mask;
101 u32 cache;
102 u8 count;
103 u8 ind;
104 u8 inversed;
105 u8 health;
106};
107
108/**
109 * struct mlxreg_core_platform_data - platform data:
110 *
111 * @led_data: led private data;
112 * @regmap: register map of parent device;
113 * @counter: number of led instances;
114 */
115struct mlxreg_core_platform_data {
116 struct mlxreg_core_data *data;
117 void *regmap;
118 int counter;
119};
120
121/**
122 * struct mlxreg_core_hotplug_platform_data - hotplug platform data:
123 *
124 * @items: same type components with the hotplug capability;
125 * @irq: platform interrupt number;
126 * @regmap: register map of parent device;
127 * @counter: number of the components with the hotplug capability;
128 * @cell: location of top aggregation interrupt register;
129 * @mask: top aggregation interrupt common mask;
130 * @cell_low: location of low aggregation interrupt register;
131 * @mask_low: low aggregation interrupt common mask;
132 */
133struct mlxreg_core_hotplug_platform_data {
134 struct mlxreg_core_item *items;
135 int irq;
136 void *regmap;
137 int counter;
138 u32 cell;
139 u32 mask;
140 u32 cell_low;
141 u32 mask_low;
142};
143
144#endif /* __LINUX_PLATFORM_DATA_MLXREG_H */
diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
index 44e630eb3d94..728d421fffe9 100644
--- a/include/linux/remoteproc.h
+++ b/include/linux/remoteproc.h
@@ -324,6 +324,7 @@ struct rproc_mem_entry {
324}; 324};
325 325
326struct rproc; 326struct rproc;
327struct firmware;
327 328
328/** 329/**
329 * struct rproc_ops - platform-specific device handlers 330 * struct rproc_ops - platform-specific device handlers
@@ -331,12 +332,24 @@ struct rproc;
331 * @stop: power off the device 332 * @stop: power off the device
332 * @kick: kick a virtqueue (virtqueue id given as a parameter) 333 * @kick: kick a virtqueue (virtqueue id given as a parameter)
333 * @da_to_va: optional platform hook to perform address translations 334 * @da_to_va: optional platform hook to perform address translations
335 * @load_rsc_table: load resource table from firmware image
336 * @find_loaded_rsc_table: find the loaded resouce table
337 * @load: load firmeware to memory, where the remote processor
338 * expects to find it
339 * @sanity_check: sanity check the fw image
340 * @get_boot_addr: get boot address to entry point specified in firmware
334 */ 341 */
335struct rproc_ops { 342struct rproc_ops {
336 int (*start)(struct rproc *rproc); 343 int (*start)(struct rproc *rproc);
337 int (*stop)(struct rproc *rproc); 344 int (*stop)(struct rproc *rproc);
338 void (*kick)(struct rproc *rproc, int vqid); 345 void (*kick)(struct rproc *rproc, int vqid);
339 void * (*da_to_va)(struct rproc *rproc, u64 da, int len); 346 void * (*da_to_va)(struct rproc *rproc, u64 da, int len);
347 int (*load_rsc_table)(struct rproc *rproc, const struct firmware *fw);
348 struct resource_table *(*find_loaded_rsc_table)(
349 struct rproc *rproc, const struct firmware *fw);
350 int (*load)(struct rproc *rproc, const struct firmware *fw);
351 int (*sanity_check)(struct rproc *rproc, const struct firmware *fw);
352 u32 (*get_boot_addr)(struct rproc *rproc, const struct firmware *fw);
340}; 353};
341 354
342/** 355/**
@@ -390,7 +403,6 @@ enum rproc_crash_type {
390 * @priv: private data which belongs to the platform-specific rproc module 403 * @priv: private data which belongs to the platform-specific rproc module
391 * @ops: platform-specific start/stop rproc handlers 404 * @ops: platform-specific start/stop rproc handlers
392 * @dev: virtual device for refcounting and common remoteproc behavior 405 * @dev: virtual device for refcounting and common remoteproc behavior
393 * @fw_ops: firmware-specific handlers
394 * @power: refcount of users who need this rproc powered up 406 * @power: refcount of users who need this rproc powered up
395 * @state: state of the device 407 * @state: state of the device
396 * @lock: lock which protects concurrent manipulations of the rproc 408 * @lock: lock which protects concurrent manipulations of the rproc
@@ -406,11 +418,11 @@ enum rproc_crash_type {
406 * @index: index of this rproc device 418 * @index: index of this rproc device
407 * @crash_handler: workqueue for handling a crash 419 * @crash_handler: workqueue for handling a crash
408 * @crash_cnt: crash counter 420 * @crash_cnt: crash counter
409 * @crash_comp: completion used to sync crash handler and the rproc reload
410 * @recovery_disabled: flag that state if recovery was disabled 421 * @recovery_disabled: flag that state if recovery was disabled
411 * @max_notifyid: largest allocated notify id. 422 * @max_notifyid: largest allocated notify id.
412 * @table_ptr: pointer to the resource table in effect 423 * @table_ptr: pointer to the resource table in effect
413 * @cached_table: copy of the resource table 424 * @cached_table: copy of the resource table
425 * @table_sz: size of @cached_table
414 * @has_iommu: flag to indicate if remote processor is behind an MMU 426 * @has_iommu: flag to indicate if remote processor is behind an MMU
415 */ 427 */
416struct rproc { 428struct rproc {
@@ -419,9 +431,8 @@ struct rproc {
419 const char *name; 431 const char *name;
420 char *firmware; 432 char *firmware;
421 void *priv; 433 void *priv;
422 const struct rproc_ops *ops; 434 struct rproc_ops *ops;
423 struct device dev; 435 struct device dev;
424 const struct rproc_fw_ops *fw_ops;
425 atomic_t power; 436 atomic_t power;
426 unsigned int state; 437 unsigned int state;
427 struct mutex lock; 438 struct mutex lock;
@@ -437,11 +448,11 @@ struct rproc {
437 int index; 448 int index;
438 struct work_struct crash_handler; 449 struct work_struct crash_handler;
439 unsigned int crash_cnt; 450 unsigned int crash_cnt;
440 struct completion crash_comp;
441 bool recovery_disabled; 451 bool recovery_disabled;
442 int max_notifyid; 452 int max_notifyid;
443 struct resource_table *table_ptr; 453 struct resource_table *table_ptr;
444 struct resource_table *cached_table; 454 struct resource_table *cached_table;
455 size_t table_sz;
445 bool has_iommu; 456 bool has_iommu;
446 bool auto_boot; 457 bool auto_boot;
447}; 458};
diff --git a/include/linux/switchtec.h b/include/linux/switchtec.h
index 6d325a7a0c19..ec93e93371fa 100644
--- a/include/linux/switchtec.h
+++ b/include/linux/switchtec.h
@@ -100,6 +100,9 @@ struct sw_event_regs {
100 u32 gpio_interrupt_hdr; 100 u32 gpio_interrupt_hdr;
101 u32 gpio_interrupt_data; 101 u32 gpio_interrupt_data;
102 u32 reserved16[4]; 102 u32 reserved16[4];
103 u32 gfms_event_hdr;
104 u32 gfms_event_data;
105 u32 reserved17[4];
103} __packed; 106} __packed;
104 107
105enum { 108enum {
diff --git a/include/media/cec.h b/include/media/cec.h
index 16341210d3ba..7cdf71d7125a 100644
--- a/include/media/cec.h
+++ b/include/media/cec.h
@@ -122,6 +122,7 @@ struct cec_adap_ops {
122 /* Low-level callbacks */ 122 /* Low-level callbacks */
123 int (*adap_enable)(struct cec_adapter *adap, bool enable); 123 int (*adap_enable)(struct cec_adapter *adap, bool enable);
124 int (*adap_monitor_all_enable)(struct cec_adapter *adap, bool enable); 124 int (*adap_monitor_all_enable)(struct cec_adapter *adap, bool enable);
125 int (*adap_monitor_pin_enable)(struct cec_adapter *adap, bool enable);
125 int (*adap_log_addr)(struct cec_adapter *adap, u8 logical_addr); 126 int (*adap_log_addr)(struct cec_adapter *adap, u8 logical_addr);
126 int (*adap_transmit)(struct cec_adapter *adap, u8 attempts, 127 int (*adap_transmit)(struct cec_adapter *adap, u8 attempts,
127 u32 signal_free_time, struct cec_msg *msg); 128 u32 signal_free_time, struct cec_msg *msg);
@@ -191,11 +192,6 @@ struct cec_adapter {
191 192
192 u32 tx_timeouts; 193 u32 tx_timeouts;
193 194
194#ifdef CONFIG_MEDIA_CEC_RC
195 bool rc_repeating;
196 int rc_last_scancode;
197 u64 rc_last_keypress;
198#endif
199#ifdef CONFIG_CEC_NOTIFIER 195#ifdef CONFIG_CEC_NOTIFIER
200 struct cec_notifier *notifier; 196 struct cec_notifier *notifier;
201#endif 197#endif
@@ -229,6 +225,18 @@ static inline bool cec_is_sink(const struct cec_adapter *adap)
229 return adap->phys_addr == 0; 225 return adap->phys_addr == 0;
230} 226}
231 227
228/**
229 * cec_is_registered() - is the CEC adapter registered?
230 *
231 * @adap: the CEC adapter, may be NULL.
232 *
233 * Return: true if the adapter is registered, false otherwise.
234 */
235static inline bool cec_is_registered(const struct cec_adapter *adap)
236{
237 return adap && adap->devnode.registered;
238}
239
232#define cec_phys_addr_exp(pa) \ 240#define cec_phys_addr_exp(pa) \
233 ((pa) >> 12), ((pa) >> 8) & 0xf, ((pa) >> 4) & 0xf, (pa) & 0xf 241 ((pa) >> 12), ((pa) >> 8) & 0xf, ((pa) >> 4) & 0xf, (pa) & 0xf
234 242
diff --git a/include/media/demux.h b/include/media/demux.h
new file mode 100644
index 000000000000..c4df6cee48e6
--- /dev/null
+++ b/include/media/demux.h
@@ -0,0 +1,589 @@
1/*
2 * demux.h
3 *
4 * The Kernel Digital TV Demux kABI defines a driver-internal interface for
5 * registering low-level, hardware specific driver to a hardware independent
6 * demux layer.
7 *
8 * Copyright (c) 2002 Convergence GmbH
9 *
10 * based on code:
11 * Copyright (c) 2000 Nokia Research Center
12 * Tampere, FINLAND
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU Lesser General Public License
16 * as published by the Free Software Foundation; either version 2.1
17 * of the License, or (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 */
25
26#ifndef __DEMUX_H
27#define __DEMUX_H
28
29#include <linux/types.h>
30#include <linux/errno.h>
31#include <linux/list.h>
32#include <linux/time.h>
33#include <linux/dvb/dmx.h>
34
35/*
36 * Common definitions
37 */
38
39/*
40 * DMX_MAX_FILTER_SIZE: Maximum length (in bytes) of a section/PES filter.
41 */
42
43#ifndef DMX_MAX_FILTER_SIZE
44#define DMX_MAX_FILTER_SIZE 18
45#endif
46
47/*
48 * DMX_MAX_SECFEED_SIZE: Maximum length (in bytes) of a private section feed
49 * filter.
50 */
51
52#ifndef DMX_MAX_SECTION_SIZE
53#define DMX_MAX_SECTION_SIZE 4096
54#endif
55#ifndef DMX_MAX_SECFEED_SIZE
56#define DMX_MAX_SECFEED_SIZE (DMX_MAX_SECTION_SIZE + 188)
57#endif
58
59/*
60 * TS packet reception
61 */
62
63/**
64 * enum ts_filter_type - filter type bitmap for dmx_ts_feed.set\(\)
65 *
66 * @TS_PACKET: Send TS packets (188 bytes) to callback (default).
67 * @TS_PAYLOAD_ONLY: In case TS_PACKET is set, only send the TS payload
68 * (<=184 bytes per packet) to callback
69 * @TS_DECODER: Send stream to built-in decoder (if present).
70 * @TS_DEMUX: In case TS_PACKET is set, send the TS to the demux
71 * device, not to the dvr device
72 */
73enum ts_filter_type {
74 TS_PACKET = 1,
75 TS_PAYLOAD_ONLY = 2,
76 TS_DECODER = 4,
77 TS_DEMUX = 8,
78};
79
80/**
81 * struct dmx_ts_feed - Structure that contains a TS feed filter
82 *
83 * @is_filtering: Set to non-zero when filtering in progress
84 * @parent: pointer to struct dmx_demux
85 * @priv: pointer to private data of the API client
86 * @set: sets the TS filter
87 * @start_filtering: starts TS filtering
88 * @stop_filtering: stops TS filtering
89 *
90 * A TS feed is typically mapped to a hardware PID filter on the demux chip.
91 * Using this API, the client can set the filtering properties to start/stop
92 * filtering TS packets on a particular TS feed.
93 */
94struct dmx_ts_feed {
95 int is_filtering;
96 struct dmx_demux *parent;
97 void *priv;
98 int (*set)(struct dmx_ts_feed *feed,
99 u16 pid,
100 int type,
101 enum dmx_ts_pes pes_type,
102 ktime_t timeout);
103 int (*start_filtering)(struct dmx_ts_feed *feed);
104 int (*stop_filtering)(struct dmx_ts_feed *feed);
105};
106
107/*
108 * Section reception
109 */
110
111/**
112 * struct dmx_section_filter - Structure that describes a section filter
113 *
114 * @filter_value: Contains up to 16 bytes (128 bits) of the TS section header
115 * that will be matched by the section filter
116 * @filter_mask: Contains a 16 bytes (128 bits) filter mask with the bits
117 * specified by @filter_value that will be used on the filter
118 * match logic.
119 * @filter_mode: Contains a 16 bytes (128 bits) filter mode.
120 * @parent: Pointer to struct dmx_section_feed.
121 * @priv: Pointer to private data of the API client.
122 *
123 *
124 * The @filter_mask controls which bits of @filter_value are compared with
125 * the section headers/payload. On a binary value of 1 in filter_mask, the
126 * corresponding bits are compared. The filter only accepts sections that are
127 * equal to filter_value in all the tested bit positions.
128 */
129struct dmx_section_filter {
130 u8 filter_value[DMX_MAX_FILTER_SIZE];
131 u8 filter_mask[DMX_MAX_FILTER_SIZE];
132 u8 filter_mode[DMX_MAX_FILTER_SIZE];
133 struct dmx_section_feed *parent; /* Back-pointer */
134 void *priv; /* Pointer to private data of the API client */
135};
136
137/**
138 * struct dmx_section_feed - Structure that contains a section feed filter
139 *
140 * @is_filtering: Set to non-zero when filtering in progress
141 * @parent: pointer to struct dmx_demux
142 * @priv: pointer to private data of the API client
143 * @check_crc: If non-zero, check the CRC values of filtered sections.
144 * @set: sets the section filter
145 * @allocate_filter: This function is used to allocate a section filter on
146 * the demux. It should only be called when no filtering
147 * is in progress on this section feed. If a filter cannot
148 * be allocated, the function fails with -ENOSPC.
149 * @release_filter: This function releases all the resources of a
150 * previously allocated section filter. The function
151 * should not be called while filtering is in progress
152 * on this section feed. After calling this function,
153 * the caller should not try to dereference the filter
154 * pointer.
155 * @start_filtering: starts section filtering
156 * @stop_filtering: stops section filtering
157 *
158 * A TS feed is typically mapped to a hardware PID filter on the demux chip.
159 * Using this API, the client can set the filtering properties to start/stop
160 * filtering TS packets on a particular TS feed.
161 */
162struct dmx_section_feed {
163 int is_filtering;
164 struct dmx_demux *parent;
165 void *priv;
166
167 int check_crc;
168
169 /* private: Used internally at dvb_demux.c */
170 u32 crc_val;
171
172 u8 *secbuf;
173 u8 secbuf_base[DMX_MAX_SECFEED_SIZE];
174 u16 secbufp, seclen, tsfeedp;
175
176 /* public: */
177 int (*set)(struct dmx_section_feed *feed,
178 u16 pid,
179 int check_crc);
180 int (*allocate_filter)(struct dmx_section_feed *feed,
181 struct dmx_section_filter **filter);
182 int (*release_filter)(struct dmx_section_feed *feed,
183 struct dmx_section_filter *filter);
184 int (*start_filtering)(struct dmx_section_feed *feed);
185 int (*stop_filtering)(struct dmx_section_feed *feed);
186};
187
188/**
189 * typedef dmx_ts_cb - DVB demux TS filter callback function prototype
190 *
191 * @buffer1: Pointer to the start of the filtered TS packets.
192 * @buffer1_length: Length of the TS data in buffer1.
193 * @buffer2: Pointer to the tail of the filtered TS packets, or NULL.
194 * @buffer2_length: Length of the TS data in buffer2.
195 * @source: Indicates which TS feed is the source of the callback.
196 *
197 * This function callback prototype, provided by the client of the demux API,
198 * is called from the demux code. The function is only called when filtering
199 * on a TS feed has been enabled using the start_filtering\(\) function at
200 * the &dmx_demux.
201 * Any TS packets that match the filter settings are copied to a circular
202 * buffer. The filtered TS packets are delivered to the client using this
203 * callback function.
204 * It is expected that the @buffer1 and @buffer2 callback parameters point to
205 * addresses within the circular buffer, but other implementations are also
206 * possible. Note that the called party should not try to free the memory
207 * the @buffer1 and @buffer2 parameters point to.
208 *
209 * When this function is called, the @buffer1 parameter typically points to
210 * the start of the first undelivered TS packet within a circular buffer.
211 * The @buffer2 buffer parameter is normally NULL, except when the received
212 * TS packets have crossed the last address of the circular buffer and
213 * "wrapped" to the beginning of the buffer. In the latter case the @buffer1
214 * parameter would contain an address within the circular buffer, while the
215 * @buffer2 parameter would contain the first address of the circular buffer.
216 * The number of bytes delivered with this function (i.e. @buffer1_length +
217 * @buffer2_length) is usually equal to the value of callback_length parameter
218 * given in the set() function, with one exception: if a timeout occurs before
219 * receiving callback_length bytes of TS data, any undelivered packets are
220 * immediately delivered to the client by calling this function. The timeout
221 * duration is controlled by the set() function in the TS Feed API.
222 *
223 * If a TS packet is received with errors that could not be fixed by the
224 * TS-level forward error correction (FEC), the Transport_error_indicator
225 * flag of the TS packet header should be set. The TS packet should not be
226 * discarded, as the error can possibly be corrected by a higher layer
227 * protocol. If the called party is slow in processing the callback, it
228 * is possible that the circular buffer eventually fills up. If this happens,
229 * the demux driver should discard any TS packets received while the buffer
230 * is full and return -EOVERFLOW.
231 *
232 * The type of data returned to the callback can be selected by the
233 * &dmx_ts_feed.@set function. The type parameter decides if the raw
234 * TS packet (TS_PACKET) or just the payload (TS_PACKET|TS_PAYLOAD_ONLY)
235 * should be returned. If additionally the TS_DECODER bit is set the stream
236 * will also be sent to the hardware MPEG decoder.
237 *
238 * Return:
239 *
240 * - 0, on success;
241 *
242 * - -EOVERFLOW, on buffer overflow.
243 */
244typedef int (*dmx_ts_cb)(const u8 *buffer1,
245 size_t buffer1_length,
246 const u8 *buffer2,
247 size_t buffer2_length,
248 struct dmx_ts_feed *source);
249
250/**
251 * typedef dmx_section_cb - DVB demux TS filter callback function prototype
252 *
253 * @buffer1: Pointer to the start of the filtered section, e.g.
254 * within the circular buffer of the demux driver.
255 * @buffer1_len: Length of the filtered section data in @buffer1,
256 * including headers and CRC.
257 * @buffer2: Pointer to the tail of the filtered section data,
258 * or NULL. Useful to handle the wrapping of a
259 * circular buffer.
260 * @buffer2_len: Length of the filtered section data in @buffer2,
261 * including headers and CRC.
262 * @source: Indicates which section feed is the source of the
263 * callback.
264 *
265 * This function callback prototype, provided by the client of the demux API,
266 * is called from the demux code. The function is only called when
267 * filtering of sections has been enabled using the function
268 * &dmx_ts_feed.@start_filtering. When the demux driver has received a
269 * complete section that matches at least one section filter, the client
270 * is notified via this callback function. Normally this function is called
271 * for each received section; however, it is also possible to deliver
272 * multiple sections with one callback, for example when the system load
273 * is high. If an error occurs while receiving a section, this
274 * function should be called with the corresponding error type set in the
275 * success field, whether or not there is data to deliver. The Section Feed
276 * implementation should maintain a circular buffer for received sections.
277 * However, this is not necessary if the Section Feed API is implemented as
278 * a client of the TS Feed API, because the TS Feed implementation then
279 * buffers the received data. The size of the circular buffer can be
280 * configured using the &dmx_ts_feed.@set function in the Section Feed API.
281 * If there is no room in the circular buffer when a new section is received,
282 * the section must be discarded. If this happens, the value of the success
283 * parameter should be DMX_OVERRUN_ERROR on the next callback.
284 */
285typedef int (*dmx_section_cb)(const u8 *buffer1,
286 size_t buffer1_len,
287 const u8 *buffer2,
288 size_t buffer2_len,
289 struct dmx_section_filter *source);
290
291/*
292 * DVB Front-End
293 */
294
295/**
296 * enum dmx_frontend_source - Used to identify the type of frontend
297 *
298 * @DMX_MEMORY_FE: The source of the demux is memory. It means that
299 * the MPEG-TS to be filtered comes from userspace,
300 * via write() syscall.
301 *
302 * @DMX_FRONTEND_0: The source of the demux is a frontend connected
303 * to the demux.
304 */
305enum dmx_frontend_source {
306 DMX_MEMORY_FE,
307 DMX_FRONTEND_0,
308};
309
310/**
311 * struct dmx_frontend - Structure that lists the frontends associated with
312 * a demux
313 *
314 * @connectivity_list: List of front-ends that can be connected to a
315 * particular demux;
316 * @source: Type of the frontend.
317 *
318 * FIXME: this structure should likely be replaced soon by some
319 * media-controller based logic.
320 */
321struct dmx_frontend {
322 struct list_head connectivity_list;
323 enum dmx_frontend_source source;
324};
325
326/*
327 * MPEG-2 TS Demux
328 */
329
330/**
331 * enum dmx_demux_caps - MPEG-2 TS Demux capabilities bitmap
332 *
333 * @DMX_TS_FILTERING: set if TS filtering is supported;
334 * @DMX_SECTION_FILTERING: set if section filtering is supported;
335 * @DMX_MEMORY_BASED_FILTERING: set if write() available.
336 *
337 * Those flags are OR'ed in the &dmx_demux.capabilities field
338 */
339enum dmx_demux_caps {
340 DMX_TS_FILTERING = 1,
341 DMX_SECTION_FILTERING = 4,
342 DMX_MEMORY_BASED_FILTERING = 8,
343};
344
345/*
346 * Demux resource type identifier.
347 */
348
349/**
350 * DMX_FE_ENTRY - Casts elements in the list of registered
351 * front-ends from the generic type struct list_head
352 * to the type * struct dmx_frontend
353 *
354 * @list: list of struct dmx_frontend
355 */
356#define DMX_FE_ENTRY(list) \
357 list_entry(list, struct dmx_frontend, connectivity_list)
358
359/**
360 * struct dmx_demux - Structure that contains the demux capabilities and
361 * callbacks.
362 *
363 * @capabilities: Bitfield of capability flags.
364 *
365 * @frontend: Front-end connected to the demux
366 *
367 * @priv: Pointer to private data of the API client
368 *
369 * @open: This function reserves the demux for use by the caller and, if
370 * necessary, initializes the demux. When the demux is no longer needed,
371 * the function @close should be called. It should be possible for
372 * multiple clients to access the demux at the same time. Thus, the
373 * function implementation should increment the demux usage count when
374 * @open is called and decrement it when @close is called.
375 * The @demux function parameter contains a pointer to the demux API and
376 * instance data.
377 * It returns:
378 * 0 on success;
379 * -EUSERS, if maximum usage count was reached;
380 * -EINVAL, on bad parameter.
381 *
382 * @close: This function reserves the demux for use by the caller and, if
383 * necessary, initializes the demux. When the demux is no longer needed,
384 * the function @close should be called. It should be possible for
385 * multiple clients to access the demux at the same time. Thus, the
386 * function implementation should increment the demux usage count when
387 * @open is called and decrement it when @close is called.
388 * The @demux function parameter contains a pointer to the demux API and
389 * instance data.
390 * It returns:
391 * 0 on success;
392 * -ENODEV, if demux was not in use (e. g. no users);
393 * -EINVAL, on bad parameter.
394 *
395 * @write: This function provides the demux driver with a memory buffer
396 * containing TS packets. Instead of receiving TS packets from the DVB
397 * front-end, the demux driver software will read packets from memory.
398 * Any clients of this demux with active TS, PES or Section filters will
399 * receive filtered data via the Demux callback API (see 0). The function
400 * returns when all the data in the buffer has been consumed by the demux.
401 * Demux hardware typically cannot read TS from memory. If this is the
402 * case, memory-based filtering has to be implemented entirely in software.
403 * The @demux function parameter contains a pointer to the demux API and
404 * instance data.
405 * The @buf function parameter contains a pointer to the TS data in
406 * kernel-space memory.
407 * The @count function parameter contains the length of the TS data.
408 * It returns:
409 * 0 on success;
410 * -ERESTARTSYS, if mutex lock was interrupted;
411 * -EINTR, if a signal handling is pending;
412 * -ENODEV, if demux was removed;
413 * -EINVAL, on bad parameter.
414 *
415 * @allocate_ts_feed: Allocates a new TS feed, which is used to filter the TS
416 * packets carrying a certain PID. The TS feed normally corresponds to a
417 * hardware PID filter on the demux chip.
418 * The @demux function parameter contains a pointer to the demux API and
419 * instance data.
420 * The @feed function parameter contains a pointer to the TS feed API and
421 * instance data.
422 * The @callback function parameter contains a pointer to the callback
423 * function for passing received TS packet.
424 * It returns:
425 * 0 on success;
426 * -ERESTARTSYS, if mutex lock was interrupted;
427 * -EBUSY, if no more TS feeds is available;
428 * -EINVAL, on bad parameter.
429 *
430 * @release_ts_feed: Releases the resources allocated with @allocate_ts_feed.
431 * Any filtering in progress on the TS feed should be stopped before
432 * calling this function.
433 * The @demux function parameter contains a pointer to the demux API and
434 * instance data.
435 * The @feed function parameter contains a pointer to the TS feed API and
436 * instance data.
437 * It returns:
438 * 0 on success;
439 * -EINVAL on bad parameter.
440 *
441 * @allocate_section_feed: Allocates a new section feed, i.e. a demux resource
442 * for filtering and receiving sections. On platforms with hardware
443 * support for section filtering, a section feed is directly mapped to
444 * the demux HW. On other platforms, TS packets are first PID filtered in
445 * hardware and a hardware section filter then emulated in software. The
446 * caller obtains an API pointer of type dmx_section_feed_t as an out
447 * parameter. Using this API the caller can set filtering parameters and
448 * start receiving sections.
449 * The @demux function parameter contains a pointer to the demux API and
450 * instance data.
451 * The @feed function parameter contains a pointer to the TS feed API and
452 * instance data.
453 * The @callback function parameter contains a pointer to the callback
454 * function for passing received TS packet.
455 * It returns:
456 * 0 on success;
457 * -EBUSY, if no more TS feeds is available;
458 * -EINVAL, on bad parameter.
459 *
460 * @release_section_feed: Releases the resources allocated with
461 * @allocate_section_feed, including allocated filters. Any filtering in
462 * progress on the section feed should be stopped before calling this
463 * function.
464 * The @demux function parameter contains a pointer to the demux API and
465 * instance data.
466 * The @feed function parameter contains a pointer to the TS feed API and
467 * instance data.
468 * It returns:
469 * 0 on success;
470 * -EINVAL, on bad parameter.
471 *
472 * @add_frontend: Registers a connectivity between a demux and a front-end,
473 * i.e., indicates that the demux can be connected via a call to
474 * @connect_frontend to use the given front-end as a TS source. The
475 * client of this function has to allocate dynamic or static memory for
476 * the frontend structure and initialize its fields before calling this
477 * function. This function is normally called during the driver
478 * initialization. The caller must not free the memory of the frontend
479 * struct before successfully calling @remove_frontend.
480 * The @demux function parameter contains a pointer to the demux API and
481 * instance data.
482 * The @frontend function parameter contains a pointer to the front-end
483 * instance data.
484 * It returns:
485 * 0 on success;
486 * -EINVAL, on bad parameter.
487 *
488 * @remove_frontend: Indicates that the given front-end, registered by a call
489 * to @add_frontend, can no longer be connected as a TS source by this
490 * demux. The function should be called when a front-end driver or a demux
491 * driver is removed from the system. If the front-end is in use, the
492 * function fails with the return value of -EBUSY. After successfully
493 * calling this function, the caller can free the memory of the frontend
494 * struct if it was dynamically allocated before the @add_frontend
495 * operation.
496 * The @demux function parameter contains a pointer to the demux API and
497 * instance data.
498 * The @frontend function parameter contains a pointer to the front-end
499 * instance data.
500 * It returns:
501 * 0 on success;
502 * -ENODEV, if the front-end was not found,
503 * -EINVAL, on bad parameter.
504 *
505 * @get_frontends: Provides the APIs of the front-ends that have been
506 * registered for this demux. Any of the front-ends obtained with this
507 * call can be used as a parameter for @connect_frontend. The include
508 * file demux.h contains the macro DMX_FE_ENTRY() for converting an
509 * element of the generic type struct &list_head * to the type
510 * struct &dmx_frontend *. The caller must not free the memory of any of
511 * the elements obtained via this function call.
512 * The @demux function parameter contains a pointer to the demux API and
513 * instance data.
514 * It returns a struct list_head pointer to the list of front-end
515 * interfaces, or NULL in the case of an empty list.
516 *
517 * @connect_frontend: Connects the TS output of the front-end to the input of
518 * the demux. A demux can only be connected to a front-end registered to
519 * the demux with the function @add_frontend. It may or may not be
520 * possible to connect multiple demuxes to the same front-end, depending
521 * on the capabilities of the HW platform. When not used, the front-end
522 * should be released by calling @disconnect_frontend.
523 * The @demux function parameter contains a pointer to the demux API and
524 * instance data.
525 * The @frontend function parameter contains a pointer to the front-end
526 * instance data.
527 * It returns:
528 * 0 on success;
529 * -EINVAL, on bad parameter.
530 *
531 * @disconnect_frontend: Disconnects the demux and a front-end previously
532 * connected by a @connect_frontend call.
533 * The @demux function parameter contains a pointer to the demux API and
534 * instance data.
535 * It returns:
536 * 0 on success;
537 * -EINVAL on bad parameter.
538 *
539 * @get_pes_pids: Get the PIDs for DMX_PES_AUDIO0, DMX_PES_VIDEO0,
540 * DMX_PES_TELETEXT0, DMX_PES_SUBTITLE0 and DMX_PES_PCR0.
541 * The @demux function parameter contains a pointer to the demux API and
542 * instance data.
543 * The @pids function parameter contains an array with five u16 elements
544 * where the PIDs will be stored.
545 * It returns:
546 * 0 on success;
547 * -EINVAL on bad parameter.
548 */
549struct dmx_demux {
550 enum dmx_demux_caps capabilities;
551 struct dmx_frontend *frontend;
552 void *priv;
553 int (*open)(struct dmx_demux *demux);
554 int (*close)(struct dmx_demux *demux);
555 int (*write)(struct dmx_demux *demux, const char __user *buf,
556 size_t count);
557 int (*allocate_ts_feed)(struct dmx_demux *demux,
558 struct dmx_ts_feed **feed,
559 dmx_ts_cb callback);
560 int (*release_ts_feed)(struct dmx_demux *demux,
561 struct dmx_ts_feed *feed);
562 int (*allocate_section_feed)(struct dmx_demux *demux,
563 struct dmx_section_feed **feed,
564 dmx_section_cb callback);
565 int (*release_section_feed)(struct dmx_demux *demux,
566 struct dmx_section_feed *feed);
567 int (*add_frontend)(struct dmx_demux *demux,
568 struct dmx_frontend *frontend);
569 int (*remove_frontend)(struct dmx_demux *demux,
570 struct dmx_frontend *frontend);
571 struct list_head *(*get_frontends)(struct dmx_demux *demux);
572 int (*connect_frontend)(struct dmx_demux *demux,
573 struct dmx_frontend *frontend);
574 int (*disconnect_frontend)(struct dmx_demux *demux);
575
576 int (*get_pes_pids)(struct dmx_demux *demux, u16 *pids);
577
578 /* private: */
579
580 /*
581 * Only used at av7110, to read some data from firmware.
582 * As this was never documented, we have no clue about what's
583 * there, and its usage on other drivers aren't encouraged.
584 */
585 int (*get_stc)(struct dmx_demux *demux, unsigned int num,
586 u64 *stc, unsigned int *base);
587};
588
589#endif /* #ifndef __DEMUX_H */
diff --git a/include/media/dmxdev.h b/include/media/dmxdev.h
new file mode 100644
index 000000000000..2f5cb2c7b6a7
--- /dev/null
+++ b/include/media/dmxdev.h
@@ -0,0 +1,212 @@
1/*
2 * dmxdev.h
3 *
4 * Copyright (C) 2000 Ralph Metzler & Marcus Metzler
5 * for convergence integrated media GmbH
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * as published by the Free Software Foundation; either version 2.1
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 */
18
19#ifndef _DMXDEV_H_
20#define _DMXDEV_H_
21
22#include <linux/types.h>
23#include <linux/spinlock.h>
24#include <linux/kernel.h>
25#include <linux/time.h>
26#include <linux/timer.h>
27#include <linux/wait.h>
28#include <linux/fs.h>
29#include <linux/string.h>
30#include <linux/mutex.h>
31#include <linux/slab.h>
32
33#include <linux/dvb/dmx.h>
34
35#include <media/dvbdev.h>
36#include <media/demux.h>
37#include <media/dvb_ringbuffer.h>
38#include <media/dvb_vb2.h>
39
40/**
41 * enum dmxdev_type - type of demux filter type.
42 *
43 * @DMXDEV_TYPE_NONE: no filter set.
44 * @DMXDEV_TYPE_SEC: section filter.
45 * @DMXDEV_TYPE_PES: Program Elementary Stream (PES) filter.
46 */
47enum dmxdev_type {
48 DMXDEV_TYPE_NONE,
49 DMXDEV_TYPE_SEC,
50 DMXDEV_TYPE_PES,
51};
52
53/**
54 * enum dmxdev_state - state machine for the dmxdev.
55 *
56 * @DMXDEV_STATE_FREE: indicates that the filter is freed.
57 * @DMXDEV_STATE_ALLOCATED: indicates that the filter was allocated
58 * to be used.
59 * @DMXDEV_STATE_SET: indicates that the filter parameters are set.
60 * @DMXDEV_STATE_GO: indicates that the filter is running.
61 * @DMXDEV_STATE_DONE: indicates that a packet was already filtered
62 * and the filter is now disabled.
63 * Set only if %DMX_ONESHOT. See
64 * &dmx_sct_filter_params.
65 * @DMXDEV_STATE_TIMEDOUT: Indicates a timeout condition.
66 */
67enum dmxdev_state {
68 DMXDEV_STATE_FREE,
69 DMXDEV_STATE_ALLOCATED,
70 DMXDEV_STATE_SET,
71 DMXDEV_STATE_GO,
72 DMXDEV_STATE_DONE,
73 DMXDEV_STATE_TIMEDOUT
74};
75
76/**
77 * struct dmxdev_feed - digital TV dmxdev feed
78 *
79 * @pid: Program ID to be filtered
80 * @ts: pointer to &struct dmx_ts_feed
81 * @next: &struct list_head pointing to the next feed.
82 */
83
84struct dmxdev_feed {
85 u16 pid;
86 struct dmx_ts_feed *ts;
87 struct list_head next;
88};
89
90/**
91 * struct dmxdev_filter - digital TV dmxdev filter
92 *
93 * @filter: a union describing a dmxdev filter.
94 * Currently used only for section filters.
95 * @filter.sec: a &struct dmx_section_filter pointer.
96 * For section filter only.
97 * @feed: a union describing a dmxdev feed.
98 * Depending on the filter type, it can be either
99 * @feed.ts or @feed.sec.
100 * @feed.ts: a &struct list_head list.
101 * For TS and PES feeds.
102 * @feed.sec: a &struct dmx_section_feed pointer.
103 * For section feed only.
104 * @params: a union describing dmxdev filter parameters.
105 * Depending on the filter type, it can be either
106 * @params.sec or @params.pes.
107 * @params.sec: a &struct dmx_sct_filter_params embedded struct.
108 * For section filter only.
109 * @params.pes: a &struct dmx_pes_filter_params embedded struct.
110 * For PES filter only.
111 * @type: type of the dmxdev filter, as defined by &enum dmxdev_type.
112 * @state: state of the dmxdev filter, as defined by &enum dmxdev_state.
113 * @dev: pointer to &struct dmxdev.
114 * @buffer: an embedded &struct dvb_ringbuffer buffer.
115 * @vb2_ctx: control struct for VB2 handler
116 * @mutex: protects the access to &struct dmxdev_filter.
117 * @timer: &struct timer_list embedded timer, used to check for
118 * feed timeouts.
119 * Only for section filter.
120 * @todo: index for the @secheader.
121 * Only for section filter.
122 * @secheader: buffer cache to parse the section header.
123 * Only for section filter.
124 */
125struct dmxdev_filter {
126 union {
127 struct dmx_section_filter *sec;
128 } filter;
129
130 union {
131 /* list of TS and PES feeds (struct dmxdev_feed) */
132 struct list_head ts;
133 struct dmx_section_feed *sec;
134 } feed;
135
136 union {
137 struct dmx_sct_filter_params sec;
138 struct dmx_pes_filter_params pes;
139 } params;
140
141 enum dmxdev_type type;
142 enum dmxdev_state state;
143 struct dmxdev *dev;
144 struct dvb_ringbuffer buffer;
145 struct dvb_vb2_ctx vb2_ctx;
146
147 struct mutex mutex;
148
149 /* only for sections */
150 struct timer_list timer;
151 int todo;
152 u8 secheader[3];
153};
154
155/**
156 * struct dmxdev - Describes a digital TV demux device.
157 *
158 * @dvbdev: pointer to &struct dvb_device associated with
159 * the demux device node.
160 * @dvr_dvbdev: pointer to &struct dvb_device associated with
161 * the dvr device node.
162 * @filter: pointer to &struct dmxdev_filter.
163 * @demux: pointer to &struct dmx_demux.
164 * @filternum: number of filters.
165 * @capabilities: demux capabilities as defined by &enum dmx_demux_caps.
166 * @exit: flag to indicate that the demux is being released.
167 * @dvr_orig_fe: pointer to &struct dmx_frontend.
168 * @dvr_buffer: embedded &struct dvb_ringbuffer for DVB output.
169 * @dvr_vb2_ctx: control struct for VB2 handler
170 * @mutex: protects the usage of this structure.
171 * @lock: protects access to &dmxdev->filter->data.
172 */
173struct dmxdev {
174 struct dvb_device *dvbdev;
175 struct dvb_device *dvr_dvbdev;
176
177 struct dmxdev_filter *filter;
178 struct dmx_demux *demux;
179
180 int filternum;
181 int capabilities;
182
183 unsigned int exit:1;
184#define DMXDEV_CAP_DUPLEX 1
185 struct dmx_frontend *dvr_orig_fe;
186
187 struct dvb_ringbuffer dvr_buffer;
188#define DVR_BUFFER_SIZE (10*188*1024)
189
190 struct dvb_vb2_ctx dvr_vb2_ctx;
191
192 struct mutex mutex;
193 spinlock_t lock;
194};
195
196/**
197 * dvb_dmxdev_init - initializes a digital TV demux and registers both demux
198 * and DVR devices.
199 *
200 * @dmxdev: pointer to &struct dmxdev.
201 * @adap: pointer to &struct dvb_adapter.
202 */
203int dvb_dmxdev_init(struct dmxdev *dmxdev, struct dvb_adapter *adap);
204
205/**
206 * dvb_dmxdev_release - releases a digital TV demux and unregisters it.
207 *
208 * @dmxdev: pointer to &struct dmxdev.
209 */
210void dvb_dmxdev_release(struct dmxdev *dmxdev);
211
212#endif /* _DMXDEV_H_ */
diff --git a/include/media/drv-intf/cx2341x.h b/include/media/drv-intf/cx2341x.h
index 9635eebaab09..33a97bfcea58 100644
--- a/include/media/drv-intf/cx2341x.h
+++ b/include/media/drv-intf/cx2341x.h
@@ -29,8 +29,8 @@ enum cx2341x_port {
29 29
30enum cx2341x_cap { 30enum cx2341x_cap {
31 CX2341X_CAP_HAS_SLICED_VBI = 1 << 0, 31 CX2341X_CAP_HAS_SLICED_VBI = 1 << 0,
32 CX2341X_CAP_HAS_TS = 1 << 1, 32 CX2341X_CAP_HAS_TS = 1 << 1,
33 CX2341X_CAP_HAS_AC3 = 1 << 2, 33 CX2341X_CAP_HAS_AC3 = 1 << 2,
34}; 34};
35 35
36struct cx2341x_mpeg_params { 36struct cx2341x_mpeg_params {
@@ -204,92 +204,92 @@ void cx2341x_handler_set_busy(struct cx2341x_handler *cxhdl, int busy);
204/* Firmware API commands */ 204/* Firmware API commands */
205 205
206/* MPEG decoder API, specific to the cx23415 */ 206/* MPEG decoder API, specific to the cx23415 */
207#define CX2341X_DEC_PING_FW 0x00 207#define CX2341X_DEC_PING_FW 0x00
208#define CX2341X_DEC_START_PLAYBACK 0x01 208#define CX2341X_DEC_START_PLAYBACK 0x01
209#define CX2341X_DEC_STOP_PLAYBACK 0x02 209#define CX2341X_DEC_STOP_PLAYBACK 0x02
210#define CX2341X_DEC_SET_PLAYBACK_SPEED 0x03 210#define CX2341X_DEC_SET_PLAYBACK_SPEED 0x03
211#define CX2341X_DEC_STEP_VIDEO 0x05 211#define CX2341X_DEC_STEP_VIDEO 0x05
212#define CX2341X_DEC_SET_DMA_BLOCK_SIZE 0x08 212#define CX2341X_DEC_SET_DMA_BLOCK_SIZE 0x08
213#define CX2341X_DEC_GET_XFER_INFO 0x09 213#define CX2341X_DEC_GET_XFER_INFO 0x09
214#define CX2341X_DEC_GET_DMA_STATUS 0x0a 214#define CX2341X_DEC_GET_DMA_STATUS 0x0a
215#define CX2341X_DEC_SCHED_DMA_FROM_HOST 0x0b 215#define CX2341X_DEC_SCHED_DMA_FROM_HOST 0x0b
216#define CX2341X_DEC_PAUSE_PLAYBACK 0x0d 216#define CX2341X_DEC_PAUSE_PLAYBACK 0x0d
217#define CX2341X_DEC_HALT_FW 0x0e 217#define CX2341X_DEC_HALT_FW 0x0e
218#define CX2341X_DEC_SET_STANDARD 0x10 218#define CX2341X_DEC_SET_STANDARD 0x10
219#define CX2341X_DEC_GET_VERSION 0x11 219#define CX2341X_DEC_GET_VERSION 0x11
220#define CX2341X_DEC_SET_STREAM_INPUT 0x14 220#define CX2341X_DEC_SET_STREAM_INPUT 0x14
221#define CX2341X_DEC_GET_TIMING_INFO 0x15 221#define CX2341X_DEC_GET_TIMING_INFO 0x15
222#define CX2341X_DEC_SET_AUDIO_MODE 0x16 222#define CX2341X_DEC_SET_AUDIO_MODE 0x16
223#define CX2341X_DEC_SET_EVENT_NOTIFICATION 0x17 223#define CX2341X_DEC_SET_EVENT_NOTIFICATION 0x17
224#define CX2341X_DEC_SET_DISPLAY_BUFFERS 0x18 224#define CX2341X_DEC_SET_DISPLAY_BUFFERS 0x18
225#define CX2341X_DEC_EXTRACT_VBI 0x19 225#define CX2341X_DEC_EXTRACT_VBI 0x19
226#define CX2341X_DEC_SET_DECODER_SOURCE 0x1a 226#define CX2341X_DEC_SET_DECODER_SOURCE 0x1a
227#define CX2341X_DEC_SET_PREBUFFERING 0x1e 227#define CX2341X_DEC_SET_PREBUFFERING 0x1e
228 228
229/* MPEG encoder API */ 229/* MPEG encoder API */
230#define CX2341X_ENC_PING_FW 0x80 230#define CX2341X_ENC_PING_FW 0x80
231#define CX2341X_ENC_START_CAPTURE 0x81 231#define CX2341X_ENC_START_CAPTURE 0x81
232#define CX2341X_ENC_STOP_CAPTURE 0x82 232#define CX2341X_ENC_STOP_CAPTURE 0x82
233#define CX2341X_ENC_SET_AUDIO_ID 0x89 233#define CX2341X_ENC_SET_AUDIO_ID 0x89
234#define CX2341X_ENC_SET_VIDEO_ID 0x8b 234#define CX2341X_ENC_SET_VIDEO_ID 0x8b
235#define CX2341X_ENC_SET_PCR_ID 0x8d 235#define CX2341X_ENC_SET_PCR_ID 0x8d
236#define CX2341X_ENC_SET_FRAME_RATE 0x8f 236#define CX2341X_ENC_SET_FRAME_RATE 0x8f
237#define CX2341X_ENC_SET_FRAME_SIZE 0x91 237#define CX2341X_ENC_SET_FRAME_SIZE 0x91
238#define CX2341X_ENC_SET_BIT_RATE 0x95 238#define CX2341X_ENC_SET_BIT_RATE 0x95
239#define CX2341X_ENC_SET_GOP_PROPERTIES 0x97 239#define CX2341X_ENC_SET_GOP_PROPERTIES 0x97
240#define CX2341X_ENC_SET_ASPECT_RATIO 0x99 240#define CX2341X_ENC_SET_ASPECT_RATIO 0x99
241#define CX2341X_ENC_SET_DNR_FILTER_MODE 0x9b 241#define CX2341X_ENC_SET_DNR_FILTER_MODE 0x9b
242#define CX2341X_ENC_SET_DNR_FILTER_PROPS 0x9d 242#define CX2341X_ENC_SET_DNR_FILTER_PROPS 0x9d
243#define CX2341X_ENC_SET_CORING_LEVELS 0x9f 243#define CX2341X_ENC_SET_CORING_LEVELS 0x9f
244#define CX2341X_ENC_SET_SPATIAL_FILTER_TYPE 0xa1 244#define CX2341X_ENC_SET_SPATIAL_FILTER_TYPE 0xa1
245#define CX2341X_ENC_SET_VBI_LINE 0xb7 245#define CX2341X_ENC_SET_VBI_LINE 0xb7
246#define CX2341X_ENC_SET_STREAM_TYPE 0xb9 246#define CX2341X_ENC_SET_STREAM_TYPE 0xb9
247#define CX2341X_ENC_SET_OUTPUT_PORT 0xbb 247#define CX2341X_ENC_SET_OUTPUT_PORT 0xbb
248#define CX2341X_ENC_SET_AUDIO_PROPERTIES 0xbd 248#define CX2341X_ENC_SET_AUDIO_PROPERTIES 0xbd
249#define CX2341X_ENC_HALT_FW 0xc3 249#define CX2341X_ENC_HALT_FW 0xc3
250#define CX2341X_ENC_GET_VERSION 0xc4 250#define CX2341X_ENC_GET_VERSION 0xc4
251#define CX2341X_ENC_SET_GOP_CLOSURE 0xc5 251#define CX2341X_ENC_SET_GOP_CLOSURE 0xc5
252#define CX2341X_ENC_GET_SEQ_END 0xc6 252#define CX2341X_ENC_GET_SEQ_END 0xc6
253#define CX2341X_ENC_SET_PGM_INDEX_INFO 0xc7 253#define CX2341X_ENC_SET_PGM_INDEX_INFO 0xc7
254#define CX2341X_ENC_SET_VBI_CONFIG 0xc8 254#define CX2341X_ENC_SET_VBI_CONFIG 0xc8
255#define CX2341X_ENC_SET_DMA_BLOCK_SIZE 0xc9 255#define CX2341X_ENC_SET_DMA_BLOCK_SIZE 0xc9
256#define CX2341X_ENC_GET_PREV_DMA_INFO_MB_10 0xca 256#define CX2341X_ENC_GET_PREV_DMA_INFO_MB_10 0xca
257#define CX2341X_ENC_GET_PREV_DMA_INFO_MB_9 0xcb 257#define CX2341X_ENC_GET_PREV_DMA_INFO_MB_9 0xcb
258#define CX2341X_ENC_SCHED_DMA_TO_HOST 0xcc 258#define CX2341X_ENC_SCHED_DMA_TO_HOST 0xcc
259#define CX2341X_ENC_INITIALIZE_INPUT 0xcd 259#define CX2341X_ENC_INITIALIZE_INPUT 0xcd
260#define CX2341X_ENC_SET_FRAME_DROP_RATE 0xd0 260#define CX2341X_ENC_SET_FRAME_DROP_RATE 0xd0
261#define CX2341X_ENC_PAUSE_ENCODER 0xd2 261#define CX2341X_ENC_PAUSE_ENCODER 0xd2
262#define CX2341X_ENC_REFRESH_INPUT 0xd3 262#define CX2341X_ENC_REFRESH_INPUT 0xd3
263#define CX2341X_ENC_SET_COPYRIGHT 0xd4 263#define CX2341X_ENC_SET_COPYRIGHT 0xd4
264#define CX2341X_ENC_SET_EVENT_NOTIFICATION 0xd5 264#define CX2341X_ENC_SET_EVENT_NOTIFICATION 0xd5
265#define CX2341X_ENC_SET_NUM_VSYNC_LINES 0xd6 265#define CX2341X_ENC_SET_NUM_VSYNC_LINES 0xd6
266#define CX2341X_ENC_SET_PLACEHOLDER 0xd7 266#define CX2341X_ENC_SET_PLACEHOLDER 0xd7
267#define CX2341X_ENC_MUTE_VIDEO 0xd9 267#define CX2341X_ENC_MUTE_VIDEO 0xd9
268#define CX2341X_ENC_MUTE_AUDIO 0xda 268#define CX2341X_ENC_MUTE_AUDIO 0xda
269#define CX2341X_ENC_SET_VERT_CROP_LINE 0xdb 269#define CX2341X_ENC_SET_VERT_CROP_LINE 0xdb
270#define CX2341X_ENC_MISC 0xdc 270#define CX2341X_ENC_MISC 0xdc
271 271
272/* OSD API, specific to the cx23415 */ 272/* OSD API, specific to the cx23415 */
273#define CX2341X_OSD_GET_FRAMEBUFFER 0x41 273#define CX2341X_OSD_GET_FRAMEBUFFER 0x41
274#define CX2341X_OSD_GET_PIXEL_FORMAT 0x42 274#define CX2341X_OSD_GET_PIXEL_FORMAT 0x42
275#define CX2341X_OSD_SET_PIXEL_FORMAT 0x43 275#define CX2341X_OSD_SET_PIXEL_FORMAT 0x43
276#define CX2341X_OSD_GET_STATE 0x44 276#define CX2341X_OSD_GET_STATE 0x44
277#define CX2341X_OSD_SET_STATE 0x45 277#define CX2341X_OSD_SET_STATE 0x45
278#define CX2341X_OSD_GET_OSD_COORDS 0x46 278#define CX2341X_OSD_GET_OSD_COORDS 0x46
279#define CX2341X_OSD_SET_OSD_COORDS 0x47 279#define CX2341X_OSD_SET_OSD_COORDS 0x47
280#define CX2341X_OSD_GET_SCREEN_COORDS 0x48 280#define CX2341X_OSD_GET_SCREEN_COORDS 0x48
281#define CX2341X_OSD_SET_SCREEN_COORDS 0x49 281#define CX2341X_OSD_SET_SCREEN_COORDS 0x49
282#define CX2341X_OSD_GET_GLOBAL_ALPHA 0x4a 282#define CX2341X_OSD_GET_GLOBAL_ALPHA 0x4a
283#define CX2341X_OSD_SET_GLOBAL_ALPHA 0x4b 283#define CX2341X_OSD_SET_GLOBAL_ALPHA 0x4b
284#define CX2341X_OSD_SET_BLEND_COORDS 0x4c 284#define CX2341X_OSD_SET_BLEND_COORDS 0x4c
285#define CX2341X_OSD_GET_FLICKER_STATE 0x4f 285#define CX2341X_OSD_GET_FLICKER_STATE 0x4f
286#define CX2341X_OSD_SET_FLICKER_STATE 0x50 286#define CX2341X_OSD_SET_FLICKER_STATE 0x50
287#define CX2341X_OSD_BLT_COPY 0x52 287#define CX2341X_OSD_BLT_COPY 0x52
288#define CX2341X_OSD_BLT_FILL 0x53 288#define CX2341X_OSD_BLT_FILL 0x53
289#define CX2341X_OSD_BLT_TEXT 0x54 289#define CX2341X_OSD_BLT_TEXT 0x54
290#define CX2341X_OSD_SET_FRAMEBUFFER_WINDOW 0x56 290#define CX2341X_OSD_SET_FRAMEBUFFER_WINDOW 0x56
291#define CX2341X_OSD_SET_CHROMA_KEY 0x60 291#define CX2341X_OSD_SET_CHROMA_KEY 0x60
292#define CX2341X_OSD_GET_ALPHA_CONTENT_INDEX 0x61 292#define CX2341X_OSD_GET_ALPHA_CONTENT_INDEX 0x61
293#define CX2341X_OSD_SET_ALPHA_CONTENT_INDEX 0x62 293#define CX2341X_OSD_SET_ALPHA_CONTENT_INDEX 0x62
294 294
295#endif /* CX2341X_H */ 295#endif /* CX2341X_H */
diff --git a/include/media/drv-intf/exynos-fimc.h b/include/media/drv-intf/exynos-fimc.h
index 69bcd2a07d5c..f9c64338841f 100644
--- a/include/media/drv-intf/exynos-fimc.h
+++ b/include/media/drv-intf/exynos-fimc.h
@@ -155,7 +155,8 @@ static inline struct exynos_video_entity *vdev_to_exynos_video_entity(
155} 155}
156 156
157#define fimc_pipeline_call(ent, op, args...) \ 157#define fimc_pipeline_call(ent, op, args...) \
158 (!(ent) ? -ENOENT : (((ent)->pipe->ops && (ent)->pipe->ops->op) ? \ 158 ((!(ent) || !(ent)->pipe) ? -ENOENT : \
159 (((ent)->pipe->ops && (ent)->pipe->ops->op) ? \
159 (ent)->pipe->ops->op(((ent)->pipe), ##args) : -ENOIOCTLCMD)) \ 160 (ent)->pipe->ops->op(((ent)->pipe), ##args) : -ENOIOCTLCMD)) \
160 161
161#endif /* S5P_FIMC_H_ */ 162#endif /* S5P_FIMC_H_ */
diff --git a/include/media/drv-intf/msp3400.h b/include/media/drv-intf/msp3400.h
index 1e6e80213a77..db98ce49e17b 100644
--- a/include/media/drv-intf/msp3400.h
+++ b/include/media/drv-intf/msp3400.h
@@ -80,17 +80,17 @@
80 */ 80 */
81 81
82/* SCART input to DSP selection */ 82/* SCART input to DSP selection */
83#define MSP_IN_SCART1 0 /* Pin SC1_IN */ 83#define MSP_IN_SCART1 0 /* Pin SC1_IN */
84#define MSP_IN_SCART2 1 /* Pin SC2_IN */ 84#define MSP_IN_SCART2 1 /* Pin SC2_IN */
85#define MSP_IN_SCART3 2 /* Pin SC3_IN */ 85#define MSP_IN_SCART3 2 /* Pin SC3_IN */
86#define MSP_IN_SCART4 3 /* Pin SC4_IN */ 86#define MSP_IN_SCART4 3 /* Pin SC4_IN */
87#define MSP_IN_MONO 6 /* Pin MONO_IN */ 87#define MSP_IN_MONO 6 /* Pin MONO_IN */
88#define MSP_IN_MUTE 7 /* Mute DSP input */ 88#define MSP_IN_MUTE 7 /* Mute DSP input */
89#define MSP_SCART_TO_DSP(in) (in) 89#define MSP_SCART_TO_DSP(in) (in)
90/* Tuner input to demodulator and DSP selection */ 90/* Tuner input to demodulator and DSP selection */
91#define MSP_IN_TUNER1 0 /* Analog Sound IF input pin ANA_IN1 */ 91#define MSP_IN_TUNER1 0 /* Analog Sound IF input pin ANA_IN1 */
92#define MSP_IN_TUNER2 1 /* Analog Sound IF input pin ANA_IN2 */ 92#define MSP_IN_TUNER2 1 /* Analog Sound IF input pin ANA_IN2 */
93#define MSP_TUNER_TO_DSP(in) ((in) << 3) 93#define MSP_TUNER_TO_DSP(in) ((in) << 3)
94 94
95/* The msp has up to 5 DSP outputs, each output can independently select 95/* The msp has up to 5 DSP outputs, each output can independently select
96 a DSP input. 96 a DSP input.
@@ -109,30 +109,30 @@
109 DSP. This is currently not implemented. Also not implemented is the 109 DSP. This is currently not implemented. Also not implemented is the
110 multi-channel capable I2S3 input of the 44x0G. If someone can demonstrate 110 multi-channel capable I2S3 input of the 44x0G. If someone can demonstrate
111 a need for one of those features then additional support can be added. */ 111 a need for one of those features then additional support can be added. */
112#define MSP_DSP_IN_TUNER 0 /* Tuner DSP input */ 112#define MSP_DSP_IN_TUNER 0 /* Tuner DSP input */
113#define MSP_DSP_IN_SCART 2 /* SCART DSP input */ 113#define MSP_DSP_IN_SCART 2 /* SCART DSP input */
114#define MSP_DSP_IN_I2S1 5 /* I2S1 DSP input */ 114#define MSP_DSP_IN_I2S1 5 /* I2S1 DSP input */
115#define MSP_DSP_IN_I2S2 6 /* I2S2 DSP input */ 115#define MSP_DSP_IN_I2S2 6 /* I2S2 DSP input */
116#define MSP_DSP_IN_I2S3 7 /* I2S3 DSP input */ 116#define MSP_DSP_IN_I2S3 7 /* I2S3 DSP input */
117#define MSP_DSP_IN_MAIN_AVC 11 /* MAIN AVC processed DSP input */ 117#define MSP_DSP_IN_MAIN_AVC 11 /* MAIN AVC processed DSP input */
118#define MSP_DSP_IN_MAIN 12 /* MAIN DSP input */ 118#define MSP_DSP_IN_MAIN 12 /* MAIN DSP input */
119#define MSP_DSP_IN_AUX 13 /* AUX DSP input */ 119#define MSP_DSP_IN_AUX 13 /* AUX DSP input */
120#define MSP_DSP_TO_MAIN(in) ((in) << 4) 120#define MSP_DSP_TO_MAIN(in) ((in) << 4)
121#define MSP_DSP_TO_AUX(in) ((in) << 8) 121#define MSP_DSP_TO_AUX(in) ((in) << 8)
122#define MSP_DSP_TO_SCART1(in) ((in) << 12) 122#define MSP_DSP_TO_SCART1(in) ((in) << 12)
123#define MSP_DSP_TO_SCART2(in) ((in) << 16) 123#define MSP_DSP_TO_SCART2(in) ((in) << 16)
124#define MSP_DSP_TO_I2S(in) ((in) << 20) 124#define MSP_DSP_TO_I2S(in) ((in) << 20)
125 125
126/* Output SCART select: the SCART outputs can select which input 126/* Output SCART select: the SCART outputs can select which input
127 to use. */ 127 to use. */
128#define MSP_SC_IN_SCART1 0 /* SCART1 input, bypassing the DSP */ 128#define MSP_SC_IN_SCART1 0 /* SCART1 input, bypassing the DSP */
129#define MSP_SC_IN_SCART2 1 /* SCART2 input, bypassing the DSP */ 129#define MSP_SC_IN_SCART2 1 /* SCART2 input, bypassing the DSP */
130#define MSP_SC_IN_SCART3 2 /* SCART3 input, bypassing the DSP */ 130#define MSP_SC_IN_SCART3 2 /* SCART3 input, bypassing the DSP */
131#define MSP_SC_IN_SCART4 3 /* SCART4 input, bypassing the DSP */ 131#define MSP_SC_IN_SCART4 3 /* SCART4 input, bypassing the DSP */
132#define MSP_SC_IN_DSP_SCART1 4 /* DSP SCART1 input */ 132#define MSP_SC_IN_DSP_SCART1 4 /* DSP SCART1 input */
133#define MSP_SC_IN_DSP_SCART2 5 /* DSP SCART2 input */ 133#define MSP_SC_IN_DSP_SCART2 5 /* DSP SCART2 input */
134#define MSP_SC_IN_MONO 6 /* MONO input, bypassing the DSP */ 134#define MSP_SC_IN_MONO 6 /* MONO input, bypassing the DSP */
135#define MSP_SC_IN_MUTE 7 /* MUTE output */ 135#define MSP_SC_IN_MUTE 7 /* MUTE output */
136#define MSP_SC_TO_SCART1(in) (in) 136#define MSP_SC_TO_SCART1(in) (in)
137#define MSP_SC_TO_SCART2(in) ((in) << 4) 137#define MSP_SC_TO_SCART2(in) ((in) << 4)
138 138
diff --git a/include/media/drv-intf/saa7146.h b/include/media/drv-intf/saa7146.h
index 769c6cf7eb4c..a7bf2c4a2e4d 100644
--- a/include/media/drv-intf/saa7146.h
+++ b/include/media/drv-intf/saa7146.h
@@ -118,7 +118,7 @@ struct saa7146_dev
118{ 118{
119 struct module *module; 119 struct module *module;
120 120
121 struct v4l2_device v4l2_dev; 121 struct v4l2_device v4l2_dev;
122 struct v4l2_ctrl_handler ctrl_handler; 122 struct v4l2_ctrl_handler ctrl_handler;
123 123
124 /* different device locks */ 124 /* different device locks */
diff --git a/include/media/dvb-usb-ids.h b/include/media/dvb-usb-ids.h
new file mode 100644
index 000000000000..28e2be5c8a98
--- /dev/null
+++ b/include/media/dvb-usb-ids.h
@@ -0,0 +1,424 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2/* dvb-usb-ids.h is part of the DVB USB library.
3 *
4 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de) see
5 * dvb-usb-init.c for copyright information.
6 *
7 * a header file containing define's for the USB device supported by the
8 * various drivers.
9 */
10#ifndef _DVB_USB_IDS_H_
11#define _DVB_USB_IDS_H_
12
13/* Vendor IDs */
14#define USB_VID_ADSTECH 0x06e1
15#define USB_VID_AFATECH 0x15a4
16#define USB_VID_ALCOR_MICRO 0x058f
17#define USB_VID_ALINK 0x05e3
18#define USB_VID_AMT 0x1c73
19#define USB_VID_ANCHOR 0x0547
20#define USB_VID_ANSONIC 0x10b9
21#define USB_VID_ANUBIS_ELECTRONIC 0x10fd
22#define USB_VID_ASUS 0x0b05
23#define USB_VID_AVERMEDIA 0x07ca
24#define USB_VID_COMPRO 0x185b
25#define USB_VID_COMPRO_UNK 0x145f
26#define USB_VID_CONEXANT 0x0572
27#define USB_VID_CYPRESS 0x04b4
28#define USB_VID_DEXATEK 0x1d19
29#define USB_VID_DIBCOM 0x10b8
30#define USB_VID_DPOSH 0x1498
31#define USB_VID_DVICO 0x0fe9
32#define USB_VID_E3C 0x18b4
33#define USB_VID_ELGATO 0x0fd9
34#define USB_VID_EMPIA 0xeb1a
35#define USB_VID_GENPIX 0x09c0
36#define USB_VID_GRANDTEC 0x5032
37#define USB_VID_GTEK 0x1f4d
38#define USB_VID_HANFTEK 0x15f4
39#define USB_VID_HAUPPAUGE 0x2040
40#define USB_VID_HYPER_PALTEK 0x1025
41#define USB_VID_INTEL 0x8086
42#define USB_VID_ITETECH 0x048d
43#define USB_VID_KWORLD 0xeb2a
44#define USB_VID_KWORLD_2 0x1b80
45#define USB_VID_KYE 0x0458
46#define USB_VID_LEADTEK 0x0413
47#define USB_VID_LITEON 0x04ca
48#define USB_VID_MEDION 0x1660
49#define USB_VID_MIGLIA 0x18f3
50#define USB_VID_MSI 0x0db0
51#define USB_VID_MSI_2 0x1462
52#define USB_VID_OPERA1 0x695c
53#define USB_VID_PINNACLE 0x2304
54#define USB_VID_PCTV 0x2013
55#define USB_VID_PIXELVIEW 0x1554
56#define USB_VID_REALTEK 0x0bda
57#define USB_VID_TECHNOTREND 0x0b48
58#define USB_VID_TERRATEC 0x0ccd
59#define USB_VID_TELESTAR 0x10b9
60#define USB_VID_VISIONPLUS 0x13d3
61#define USB_VID_SONY 0x1415
62#define USB_PID_TEVII_S421 0xd421
63#define USB_PID_TEVII_S480_1 0xd481
64#define USB_PID_TEVII_S480_2 0xd482
65#define USB_PID_TEVII_S630 0xd630
66#define USB_PID_TEVII_S632 0xd632
67#define USB_PID_TEVII_S650 0xd650
68#define USB_PID_TEVII_S660 0xd660
69#define USB_PID_TEVII_S662 0xd662
70#define USB_VID_TWINHAN 0x1822
71#define USB_VID_ULTIMA_ELECTRONIC 0x05d8
72#define USB_VID_UNIWILL 0x1584
73#define USB_VID_WIDEVIEW 0x14aa
74#define USB_VID_GIGABYTE 0x1044
75#define USB_VID_YUAN 0x1164
76#define USB_VID_XTENSIONS 0x1ae7
77#define USB_VID_ZYDAS 0x0ace
78#define USB_VID_HUMAX_COEX 0x10b9
79#define USB_VID_774 0x7a69
80#define USB_VID_EVOLUTEPC 0x1e59
81#define USB_VID_AZUREWAVE 0x13d3
82#define USB_VID_TECHNISAT 0x14f7
83#define USB_VID_HAMA 0x147f
84#define USB_VID_MICROSOFT 0x045e
85
86/* Product IDs */
87#define USB_PID_ADSTECH_USB2_COLD 0xa333
88#define USB_PID_ADSTECH_USB2_WARM 0xa334
89#define USB_PID_AFATECH_AF9005 0x9020
90#define USB_PID_AFATECH_AF9015_9015 0x9015
91#define USB_PID_AFATECH_AF9015_9016 0x9016
92#define USB_PID_AFATECH_AF9035_1000 0x1000
93#define USB_PID_AFATECH_AF9035_1001 0x1001
94#define USB_PID_AFATECH_AF9035_1002 0x1002
95#define USB_PID_AFATECH_AF9035_1003 0x1003
96#define USB_PID_AFATECH_AF9035_9035 0x9035
97#define USB_PID_TREKSTOR_DVBT 0x901b
98#define USB_PID_TREKSTOR_TERRES_2_0 0xC803
99#define USB_VID_ALINK_DTU 0xf170
100#define USB_PID_ANSONIC_DVBT_USB 0x6000
101#define USB_PID_ANYSEE 0x861f
102#define USB_PID_AZUREWAVE_AD_TU700 0x3237
103#define USB_PID_AZUREWAVE_6007 0x0ccd
104#define USB_PID_AVERMEDIA_DVBT_USB_COLD 0x0001
105#define USB_PID_AVERMEDIA_DVBT_USB_WARM 0x0002
106#define USB_PID_AVERMEDIA_DVBT_USB2_COLD 0xa800
107#define USB_PID_AVERMEDIA_DVBT_USB2_WARM 0xa801
108#define USB_PID_COMPRO_DVBU2000_COLD 0xd000
109#define USB_PID_COMPRO_DVBU2000_WARM 0xd001
110#define USB_PID_COMPRO_DVBU2000_UNK_COLD 0x010c
111#define USB_PID_COMPRO_DVBU2000_UNK_WARM 0x010d
112#define USB_PID_COMPRO_VIDEOMATE_U500 0x1e78
113#define USB_PID_COMPRO_VIDEOMATE_U500_PC 0x1e80
114#define USB_PID_CONCEPTRONIC_CTVDIGRCU 0xe397
115#define USB_PID_CONEXANT_D680_DMB 0x86d6
116#define USB_PID_CREATIX_CTX1921 0x1921
117#define USB_PID_DELOCK_USB2_DVBT 0xb803
118#define USB_PID_DIBCOM_HOOK_DEFAULT 0x0064
119#define USB_PID_DIBCOM_HOOK_DEFAULT_REENUM 0x0065
120#define USB_PID_DIBCOM_MOD3000_COLD 0x0bb8
121#define USB_PID_DIBCOM_MOD3000_WARM 0x0bb9
122#define USB_PID_DIBCOM_MOD3001_COLD 0x0bc6
123#define USB_PID_DIBCOM_MOD3001_WARM 0x0bc7
124#define USB_PID_DIBCOM_STK7700P 0x1e14
125#define USB_PID_DIBCOM_STK7700P_PC 0x1e78
126#define USB_PID_DIBCOM_STK7700D 0x1ef0
127#define USB_PID_DIBCOM_STK7700_U7000 0x7001
128#define USB_PID_DIBCOM_STK7070P 0x1ebc
129#define USB_PID_DIBCOM_STK7070PD 0x1ebe
130#define USB_PID_DIBCOM_STK807XP 0x1f90
131#define USB_PID_DIBCOM_STK807XPVR 0x1f98
132#define USB_PID_DIBCOM_STK8096GP 0x1fa0
133#define USB_PID_DIBCOM_STK8096PVR 0x1faa
134#define USB_PID_DIBCOM_NIM8096MD 0x1fa8
135#define USB_PID_DIBCOM_TFE8096P 0x1f9C
136#define USB_PID_DIBCOM_ANCHOR_2135_COLD 0x2131
137#define USB_PID_DIBCOM_STK7770P 0x1e80
138#define USB_PID_DIBCOM_NIM7090 0x1bb2
139#define USB_PID_DIBCOM_TFE7090PVR 0x1bb4
140#define USB_PID_DIBCOM_TFE7790P 0x1e6e
141#define USB_PID_DIBCOM_NIM9090M 0x2383
142#define USB_PID_DIBCOM_NIM9090MD 0x2384
143#define USB_PID_DPOSH_M9206_COLD 0x9206
144#define USB_PID_DPOSH_M9206_WARM 0xa090
145#define USB_PID_E3C_EC168 0x1689
146#define USB_PID_E3C_EC168_2 0xfffa
147#define USB_PID_E3C_EC168_3 0xfffb
148#define USB_PID_E3C_EC168_4 0x1001
149#define USB_PID_E3C_EC168_5 0x1002
150#define USB_PID_FREECOM_DVBT 0x0160
151#define USB_PID_FREECOM_DVBT_2 0x0161
152#define USB_PID_UNIWILL_STK7700P 0x6003
153#define USB_PID_GENIUS_TVGO_DVB_T03 0x4012
154#define USB_PID_GRANDTEC_DVBT_USB_COLD 0x0fa0
155#define USB_PID_GRANDTEC_DVBT_USB_WARM 0x0fa1
156#define USB_PID_GOTVIEW_SAT_HD 0x5456
157#define USB_PID_INTEL_CE9500 0x9500
158#define USB_PID_ITETECH_IT9135 0x9135
159#define USB_PID_ITETECH_IT9135_9005 0x9005
160#define USB_PID_ITETECH_IT9135_9006 0x9006
161#define USB_PID_ITETECH_IT9303 0x9306
162#define USB_PID_KWORLD_399U 0xe399
163#define USB_PID_KWORLD_399U_2 0xe400
164#define USB_PID_KWORLD_395U 0xe396
165#define USB_PID_KWORLD_395U_2 0xe39b
166#define USB_PID_KWORLD_395U_3 0xe395
167#define USB_PID_KWORLD_395U_4 0xe39a
168#define USB_PID_KWORLD_MC810 0xc810
169#define USB_PID_KWORLD_PC160_2T 0xc160
170#define USB_PID_KWORLD_PC160_T 0xc161
171#define USB_PID_KWORLD_UB383_T 0xe383
172#define USB_PID_KWORLD_UB499_2T_T09 0xe409
173#define USB_PID_KWORLD_VSTREAM_COLD 0x17de
174#define USB_PID_KWORLD_VSTREAM_WARM 0x17df
175#define USB_PID_PROF_1100 0xb012
176#define USB_PID_TERRATEC_CINERGY_S 0x0064
177#define USB_PID_TERRATEC_CINERGY_T_USB_XE 0x0055
178#define USB_PID_TERRATEC_CINERGY_T_USB_XE_REV2 0x0069
179#define USB_PID_TERRATEC_CINERGY_T_STICK 0x0093
180#define USB_PID_TERRATEC_CINERGY_T_STICK_RC 0x0097
181#define USB_PID_TERRATEC_CINERGY_T_STICK_DUAL_RC 0x0099
182#define USB_PID_TERRATEC_CINERGY_T_STICK_BLACK_REV1 0x00a9
183#define USB_PID_TWINHAN_VP7041_COLD 0x3201
184#define USB_PID_TWINHAN_VP7041_WARM 0x3202
185#define USB_PID_TWINHAN_VP7020_COLD 0x3203
186#define USB_PID_TWINHAN_VP7020_WARM 0x3204
187#define USB_PID_TWINHAN_VP7045_COLD 0x3205
188#define USB_PID_TWINHAN_VP7045_WARM 0x3206
189#define USB_PID_TWINHAN_VP7021_COLD 0x3207
190#define USB_PID_TWINHAN_VP7021_WARM 0x3208
191#define USB_PID_TWINHAN_VP7049 0x3219
192#define USB_PID_TINYTWIN 0x3226
193#define USB_PID_TINYTWIN_2 0xe402
194#define USB_PID_TINYTWIN_3 0x9016
195#define USB_PID_DNTV_TINYUSB2_COLD 0x3223
196#define USB_PID_DNTV_TINYUSB2_WARM 0x3224
197#define USB_PID_ULTIMA_TVBOX_COLD 0x8105
198#define USB_PID_ULTIMA_TVBOX_WARM 0x8106
199#define USB_PID_ULTIMA_TVBOX_AN2235_COLD 0x8107
200#define USB_PID_ULTIMA_TVBOX_AN2235_WARM 0x8108
201#define USB_PID_ULTIMA_TVBOX_ANCHOR_COLD 0x2235
202#define USB_PID_ULTIMA_TVBOX_USB2_COLD 0x8109
203#define USB_PID_ULTIMA_TVBOX_USB2_WARM 0x810a
204#define USB_PID_ARTEC_T14_COLD 0x810b
205#define USB_PID_ARTEC_T14_WARM 0x810c
206#define USB_PID_ARTEC_T14BR 0x810f
207#define USB_PID_ULTIMA_TVBOX_USB2_FX_COLD 0x8613
208#define USB_PID_ULTIMA_TVBOX_USB2_FX_WARM 0x1002
209#define USB_PID_UNK_HYPER_PALTEK_COLD 0x005e
210#define USB_PID_UNK_HYPER_PALTEK_WARM 0x005f
211#define USB_PID_HANFTEK_UMT_010_COLD 0x0001
212#define USB_PID_HANFTEK_UMT_010_WARM 0x0015
213#define USB_PID_DTT200U_COLD 0x0201
214#define USB_PID_DTT200U_WARM 0x0301
215#define USB_PID_WT220U_ZAP250_COLD 0x0220
216#define USB_PID_WT220U_COLD 0x0222
217#define USB_PID_WT220U_WARM 0x0221
218#define USB_PID_WT220U_FC_COLD 0x0225
219#define USB_PID_WT220U_FC_WARM 0x0226
220#define USB_PID_WT220U_ZL0353_COLD 0x022a
221#define USB_PID_WT220U_ZL0353_WARM 0x022b
222#define USB_PID_WINTV_NOVA_T_USB2_COLD 0x9300
223#define USB_PID_WINTV_NOVA_T_USB2_WARM 0x9301
224#define USB_PID_HAUPPAUGE_NOVA_T_500 0x9941
225#define USB_PID_HAUPPAUGE_NOVA_T_500_2 0x9950
226#define USB_PID_HAUPPAUGE_NOVA_T_500_3 0x8400
227#define USB_PID_HAUPPAUGE_NOVA_T_STICK 0x7050
228#define USB_PID_HAUPPAUGE_NOVA_T_STICK_2 0x7060
229#define USB_PID_HAUPPAUGE_NOVA_T_STICK_3 0x7070
230#define USB_PID_HAUPPAUGE_MYTV_T 0x7080
231#define USB_PID_HAUPPAUGE_NOVA_TD_STICK 0x9580
232#define USB_PID_HAUPPAUGE_NOVA_TD_STICK_52009 0x5200
233#define USB_PID_HAUPPAUGE_TIGER_ATSC 0xb200
234#define USB_PID_HAUPPAUGE_TIGER_ATSC_B210 0xb210
235#define USB_PID_AVERMEDIA_EXPRESS 0xb568
236#define USB_PID_AVERMEDIA_VOLAR 0xa807
237#define USB_PID_AVERMEDIA_VOLAR_2 0xb808
238#define USB_PID_AVERMEDIA_VOLAR_A868R 0xa868
239#define USB_PID_AVERMEDIA_MCE_USB_M038 0x1228
240#define USB_PID_AVERMEDIA_HYBRID_ULTRA_USB_M039R 0x0039
241#define USB_PID_AVERMEDIA_HYBRID_ULTRA_USB_M039R_ATSC 0x1039
242#define USB_PID_AVERMEDIA_HYBRID_ULTRA_USB_M039R_DVBT 0x2039
243#define USB_PID_AVERMEDIA_VOLAR_X 0xa815
244#define USB_PID_AVERMEDIA_VOLAR_X_2 0x8150
245#define USB_PID_AVERMEDIA_A309 0xa309
246#define USB_PID_AVERMEDIA_A310 0xa310
247#define USB_PID_AVERMEDIA_A850 0x850a
248#define USB_PID_AVERMEDIA_A850T 0x850b
249#define USB_PID_AVERMEDIA_A805 0xa805
250#define USB_PID_AVERMEDIA_A815M 0x815a
251#define USB_PID_AVERMEDIA_A835 0xa835
252#define USB_PID_AVERMEDIA_B835 0xb835
253#define USB_PID_AVERMEDIA_A835B_1835 0x1835
254#define USB_PID_AVERMEDIA_A835B_2835 0x2835
255#define USB_PID_AVERMEDIA_A835B_3835 0x3835
256#define USB_PID_AVERMEDIA_A835B_4835 0x4835
257#define USB_PID_AVERMEDIA_1867 0x1867
258#define USB_PID_AVERMEDIA_A867 0xa867
259#define USB_PID_AVERMEDIA_H335 0x0335
260#define USB_PID_AVERMEDIA_TD110 0xa110
261#define USB_PID_AVERMEDIA_TWINSTAR 0x0825
262#define USB_PID_TECHNOTREND_CONNECT_S2400 0x3006
263#define USB_PID_TECHNOTREND_CONNECT_S2400_8KEEPROM 0x3009
264#define USB_PID_TECHNOTREND_CONNECT_CT3650 0x300d
265#define USB_PID_TECHNOTREND_CONNECT_S2_4600 0x3011
266#define USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI 0x3012
267#define USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI_2 0x3015
268#define USB_PID_TECHNOTREND_TVSTICK_CT2_4400 0x3014
269#define USB_PID_TECHNOTREND_CONNECT_S2_4650_CI 0x3017
270#define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY 0x005a
271#define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2 0x0081
272#define USB_PID_TERRATEC_CINERGY_HT_USB_XE 0x0058
273#define USB_PID_TERRATEC_CINERGY_HT_EXPRESS 0x0060
274#define USB_PID_TERRATEC_CINERGY_T_EXPRESS 0x0062
275#define USB_PID_TERRATEC_CINERGY_T_XXS 0x0078
276#define USB_PID_TERRATEC_CINERGY_T_XXS_2 0x00ab
277#define USB_PID_TERRATEC_CINERGY_S2_R1 0x00a8
278#define USB_PID_TERRATEC_CINERGY_S2_R2 0x00b0
279#define USB_PID_TERRATEC_CINERGY_S2_R3 0x0102
280#define USB_PID_TERRATEC_CINERGY_S2_R4 0x0105
281#define USB_PID_TERRATEC_H7 0x10b4
282#define USB_PID_TERRATEC_H7_2 0x10a3
283#define USB_PID_TERRATEC_H7_3 0x10a5
284#define USB_PID_TERRATEC_T1 0x10ae
285#define USB_PID_TERRATEC_T3 0x10a0
286#define USB_PID_TERRATEC_T5 0x10a1
287#define USB_PID_NOXON_DAB_STICK 0x00b3
288#define USB_PID_NOXON_DAB_STICK_REV2 0x00e0
289#define USB_PID_NOXON_DAB_STICK_REV3 0x00b4
290#define USB_PID_PINNACLE_EXPRESSCARD_320CX 0x022e
291#define USB_PID_PINNACLE_PCTV2000E 0x022c
292#define USB_PID_PINNACLE_PCTV_DVB_T_FLASH 0x0228
293#define USB_PID_PINNACLE_PCTV_DUAL_DIVERSITY_DVB_T 0x0229
294#define USB_PID_PINNACLE_PCTV71E 0x022b
295#define USB_PID_PINNACLE_PCTV72E 0x0236
296#define USB_PID_PINNACLE_PCTV73E 0x0237
297#define USB_PID_PINNACLE_PCTV310E 0x3211
298#define USB_PID_PINNACLE_PCTV801E 0x023a
299#define USB_PID_PINNACLE_PCTV801E_SE 0x023b
300#define USB_PID_PINNACLE_PCTV340E 0x023d
301#define USB_PID_PINNACLE_PCTV340E_SE 0x023e
302#define USB_PID_PINNACLE_PCTV73A 0x0243
303#define USB_PID_PINNACLE_PCTV73ESE 0x0245
304#define USB_PID_PINNACLE_PCTV74E 0x0246
305#define USB_PID_PINNACLE_PCTV282E 0x0248
306#define USB_PID_PIXELVIEW_SBTVD 0x5010
307#define USB_PID_PCTV_200E 0x020e
308#define USB_PID_PCTV_400E 0x020f
309#define USB_PID_PCTV_450E 0x0222
310#define USB_PID_PCTV_452E 0x021f
311#define USB_PID_PCTV_78E 0x025a
312#define USB_PID_PCTV_79E 0x0262
313#define USB_PID_REALTEK_RTL2831U 0x2831
314#define USB_PID_REALTEK_RTL2832U 0x2832
315#define USB_PID_TECHNOTREND_CONNECT_S2_3600 0x3007
316#define USB_PID_TECHNOTREND_CONNECT_S2_3650_CI 0x300a
317#define USB_PID_NEBULA_DIGITV 0x0201
318#define USB_PID_DVICO_BLUEBIRD_LGDT 0xd820
319#define USB_PID_DVICO_BLUEBIRD_LG064F_COLD 0xd500
320#define USB_PID_DVICO_BLUEBIRD_LG064F_WARM 0xd501
321#define USB_PID_DVICO_BLUEBIRD_LGZ201_COLD 0xdb00
322#define USB_PID_DVICO_BLUEBIRD_LGZ201_WARM 0xdb01
323#define USB_PID_DVICO_BLUEBIRD_TH7579_COLD 0xdb10
324#define USB_PID_DVICO_BLUEBIRD_TH7579_WARM 0xdb11
325#define USB_PID_DVICO_BLUEBIRD_DUAL_1_COLD 0xdb50
326#define USB_PID_DVICO_BLUEBIRD_DUAL_1_WARM 0xdb51
327#define USB_PID_DVICO_BLUEBIRD_DUAL_2_COLD 0xdb58
328#define USB_PID_DVICO_BLUEBIRD_DUAL_2_WARM 0xdb59
329#define USB_PID_DVICO_BLUEBIRD_DUAL_4 0xdb78
330#define USB_PID_DVICO_BLUEBIRD_DUAL_4_REV_2 0xdb98
331#define USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2 0xdb70
332#define USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM 0xdb71
333#define USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_COLD 0xdb54
334#define USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_WARM 0xdb55
335#define USB_PID_MEDION_MD95700 0x0932
336#define USB_PID_MSI_MEGASKY580 0x5580
337#define USB_PID_MSI_MEGASKY580_55801 0x5581
338#define USB_PID_KYE_DVB_T_COLD 0x701e
339#define USB_PID_KYE_DVB_T_WARM 0x701f
340#define USB_PID_LITEON_DVB_T_COLD 0xf000
341#define USB_PID_LITEON_DVB_T_WARM 0xf001
342#define USB_PID_DIGIVOX_MINI_SL_COLD 0xe360
343#define USB_PID_DIGIVOX_MINI_SL_WARM 0xe361
344#define USB_PID_GRANDTEC_DVBT_USB2_COLD 0x0bc6
345#define USB_PID_GRANDTEC_DVBT_USB2_WARM 0x0bc7
346#define USB_PID_WINFAST_DTV2000DS 0x6a04
347#define USB_PID_WINFAST_DTV2000DS_PLUS 0x6f12
348#define USB_PID_WINFAST_DTV_DONGLE_COLD 0x6025
349#define USB_PID_WINFAST_DTV_DONGLE_WARM 0x6026
350#define USB_PID_WINFAST_DTV_DONGLE_STK7700P 0x6f00
351#define USB_PID_WINFAST_DTV_DONGLE_H 0x60f6
352#define USB_PID_WINFAST_DTV_DONGLE_STK7700P_2 0x6f01
353#define USB_PID_WINFAST_DTV_DONGLE_GOLD 0x6029
354#define USB_PID_WINFAST_DTV_DONGLE_MINID 0x6f0f
355#define USB_PID_GENPIX_8PSK_REV_1_COLD 0x0200
356#define USB_PID_GENPIX_8PSK_REV_1_WARM 0x0201
357#define USB_PID_GENPIX_8PSK_REV_2 0x0202
358#define USB_PID_GENPIX_SKYWALKER_1 0x0203
359#define USB_PID_GENPIX_SKYWALKER_CW3K 0x0204
360#define USB_PID_GENPIX_SKYWALKER_2 0x0206
361#define USB_PID_SIGMATEK_DVB_110 0x6610
362#define USB_PID_MSI_DIGI_VOX_MINI_II 0x1513
363#define USB_PID_MSI_DIGIVOX_DUO 0x8801
364#define USB_PID_OPERA1_COLD 0x2830
365#define USB_PID_OPERA1_WARM 0x3829
366#define USB_PID_LIFEVIEW_TV_WALKER_TWIN_COLD 0x0514
367#define USB_PID_LIFEVIEW_TV_WALKER_TWIN_WARM 0x0513
368#define USB_PID_GIGABYTE_U7000 0x7001
369#define USB_PID_GIGABYTE_U8000 0x7002
370#define USB_PID_ASUS_U3000 0x171f
371#define USB_PID_ASUS_U3000H 0x1736
372#define USB_PID_ASUS_U3100 0x173f
373#define USB_PID_ASUS_U3100MINI_PLUS 0x1779
374#define USB_PID_YUAN_EC372S 0x1edc
375#define USB_PID_YUAN_STK7700PH 0x1f08
376#define USB_PID_YUAN_PD378S 0x2edc
377#define USB_PID_YUAN_MC770 0x0871
378#define USB_PID_YUAN_STK7700D 0x1efc
379#define USB_PID_YUAN_STK7700D_2 0x1e8c
380#define USB_PID_DW2102 0x2102
381#define USB_PID_DW2104 0x2104
382#define USB_PID_DW3101 0x3101
383#define USB_PID_XTENSIONS_XD_380 0x0381
384#define USB_PID_TELESTAR_STARSTICK_2 0x8000
385#define USB_PID_MSI_DIGI_VOX_MINI_III 0x8807
386#define USB_PID_SONY_PLAYTV 0x0003
387#define USB_PID_MYGICA_D689 0xd811
388#define USB_PID_MYGICA_T230 0xc688
389#define USB_PID_MYGICA_T230C 0xc689
390#define USB_PID_ELGATO_EYETV_DIVERSITY 0x0011
391#define USB_PID_ELGATO_EYETV_DTT 0x0021
392#define USB_PID_ELGATO_EYETV_DTT_2 0x003f
393#define USB_PID_ELGATO_EYETV_DTT_Dlx 0x0020
394#define USB_PID_ELGATO_EYETV_SAT 0x002a
395#define USB_PID_ELGATO_EYETV_SAT_V2 0x0025
396#define USB_PID_ELGATO_EYETV_SAT_V3 0x0036
397#define USB_PID_DVB_T_USB_STICK_HIGH_SPEED_COLD 0x5000
398#define USB_PID_DVB_T_USB_STICK_HIGH_SPEED_WARM 0x5001
399#define USB_PID_FRIIO_WHITE 0x0001
400#define USB_PID_TVWAY_PLUS 0x0002
401#define USB_PID_SVEON_STV20 0xe39d
402#define USB_PID_SVEON_STV20_RTL2832U 0xd39d
403#define USB_PID_SVEON_STV21 0xd3b0
404#define USB_PID_SVEON_STV22 0xe401
405#define USB_PID_SVEON_STV22_IT9137 0xe411
406#define USB_PID_AZUREWAVE_AZ6027 0x3275
407#define USB_PID_TERRATEC_DVBS2CI_V1 0x10a4
408#define USB_PID_TERRATEC_DVBS2CI_V2 0x10ac
409#define USB_PID_TECHNISAT_USB2_HDCI_V1 0x0001
410#define USB_PID_TECHNISAT_USB2_HDCI_V2 0x0002
411#define USB_PID_TECHNISAT_USB2_CABLESTAR_HDCI 0x0003
412#define USB_PID_TECHNISAT_AIRSTAR_TELESTICK_2 0x0004
413#define USB_PID_TECHNISAT_USB2_DVB_S2 0x0500
414#define USB_PID_CPYTO_REDI_PC50A 0xa803
415#define USB_PID_CTVDIGDUAL_V2 0xe410
416#define USB_PID_PCTV_2002E 0x025c
417#define USB_PID_PCTV_2002E_SE 0x025d
418#define USB_PID_SVEON_STV27 0xd3af
419#define USB_PID_TURBOX_DTT_2000 0xd3a4
420#define USB_PID_WINTV_SOLOHD 0x0264
421#define USB_PID_EVOLVEO_XTRATV_STICK 0xa115
422#define USB_PID_HAMA_DVBT_HYBRID 0x2758
423#define USB_PID_XBOX_ONE_TUNER 0x02d5
424#endif
diff --git a/include/media/dvb_ca_en50221.h b/include/media/dvb_ca_en50221.h
new file mode 100644
index 000000000000..a1c014b0a837
--- /dev/null
+++ b/include/media/dvb_ca_en50221.h
@@ -0,0 +1,142 @@
1/*
2 * dvb_ca.h: generic DVB functions for EN50221 CA interfaces
3 *
4 * Copyright (C) 2004 Andrew de Quincey
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public License
8 * as published by the Free Software Foundation; either version 2.1
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17#ifndef _DVB_CA_EN50221_H_
18#define _DVB_CA_EN50221_H_
19
20#include <linux/list.h>
21#include <linux/dvb/ca.h>
22
23#include <media/dvbdev.h>
24
25#define DVB_CA_EN50221_POLL_CAM_PRESENT 1
26#define DVB_CA_EN50221_POLL_CAM_CHANGED 2
27#define DVB_CA_EN50221_POLL_CAM_READY 4
28
29#define DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE 1
30#define DVB_CA_EN50221_FLAG_IRQ_FR 2
31#define DVB_CA_EN50221_FLAG_IRQ_DA 4
32
33#define DVB_CA_EN50221_CAMCHANGE_REMOVED 0
34#define DVB_CA_EN50221_CAMCHANGE_INSERTED 1
35
36/**
37 * struct dvb_ca_en50221- Structure describing a CA interface
38 *
39 * @owner: the module owning this structure
40 * @read_attribute_mem: function for reading attribute memory on the CAM
41 * @write_attribute_mem: function for writing attribute memory on the CAM
42 * @read_cam_control: function for reading the control interface on the CAM
43 * @write_cam_control: function for reading the control interface on the CAM
44 * @read_data: function for reading data (block mode)
45 * @write_data: function for writing data (block mode)
46 * @slot_reset: function to reset the CAM slot
47 * @slot_shutdown: function to shutdown a CAM slot
48 * @slot_ts_enable: function to enable the Transport Stream on a CAM slot
49 * @poll_slot_status: function to poll slot status. Only necessary if
50 * DVB_CA_FLAG_EN50221_IRQ_CAMCHANGE is not set.
51 * @data: private data, used by caller.
52 * @private: Opaque data used by the dvb_ca core. Do not modify!
53 *
54 * NOTE: the read_*, write_* and poll_slot_status functions will be
55 * called for different slots concurrently and need to use locks where
56 * and if appropriate. There will be no concurrent access to one slot.
57 */
58struct dvb_ca_en50221 {
59 struct module *owner;
60
61 int (*read_attribute_mem)(struct dvb_ca_en50221 *ca,
62 int slot, int address);
63 int (*write_attribute_mem)(struct dvb_ca_en50221 *ca,
64 int slot, int address, u8 value);
65
66 int (*read_cam_control)(struct dvb_ca_en50221 *ca,
67 int slot, u8 address);
68 int (*write_cam_control)(struct dvb_ca_en50221 *ca,
69 int slot, u8 address, u8 value);
70
71 int (*read_data)(struct dvb_ca_en50221 *ca,
72 int slot, u8 *ebuf, int ecount);
73 int (*write_data)(struct dvb_ca_en50221 *ca,
74 int slot, u8 *ebuf, int ecount);
75
76 int (*slot_reset)(struct dvb_ca_en50221 *ca, int slot);
77 int (*slot_shutdown)(struct dvb_ca_en50221 *ca, int slot);
78 int (*slot_ts_enable)(struct dvb_ca_en50221 *ca, int slot);
79
80 int (*poll_slot_status)(struct dvb_ca_en50221 *ca, int slot, int open);
81
82 void *data;
83
84 void *private;
85};
86
87/*
88 * Functions for reporting IRQ events
89 */
90
91/**
92 * dvb_ca_en50221_camchange_irq - A CAMCHANGE IRQ has occurred.
93 *
94 * @pubca: CA instance.
95 * @slot: Slot concerned.
96 * @change_type: One of the DVB_CA_CAMCHANGE_* values
97 */
98void dvb_ca_en50221_camchange_irq(struct dvb_ca_en50221 *pubca, int slot,
99 int change_type);
100
101/**
102 * dvb_ca_en50221_camready_irq - A CAMREADY IRQ has occurred.
103 *
104 * @pubca: CA instance.
105 * @slot: Slot concerned.
106 */
107void dvb_ca_en50221_camready_irq(struct dvb_ca_en50221 *pubca, int slot);
108
109/**
110 * dvb_ca_en50221_frda_irq - An FR or a DA IRQ has occurred.
111 *
112 * @ca: CA instance.
113 * @slot: Slot concerned.
114 */
115void dvb_ca_en50221_frda_irq(struct dvb_ca_en50221 *ca, int slot);
116
117/*
118 * Initialisation/shutdown functions
119 */
120
121/**
122 * dvb_ca_en50221_init - Initialise a new DVB CA device.
123 *
124 * @dvb_adapter: DVB adapter to attach the new CA device to.
125 * @ca: The dvb_ca instance.
126 * @flags: Flags describing the CA device (DVB_CA_EN50221_FLAG_*).
127 * @slot_count: Number of slots supported.
128 *
129 * @return 0 on success, nonzero on failure
130 */
131int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
132 struct dvb_ca_en50221 *ca, int flags,
133 int slot_count);
134
135/**
136 * dvb_ca_en50221_release - Release a DVB CA device.
137 *
138 * @ca: The associated dvb_ca instance.
139 */
140void dvb_ca_en50221_release(struct dvb_ca_en50221 *ca);
141
142#endif
diff --git a/include/media/dvb_demux.h b/include/media/dvb_demux.h
new file mode 100644
index 000000000000..b07092038f4b
--- /dev/null
+++ b/include/media/dvb_demux.h
@@ -0,0 +1,350 @@
1/*
2 * dvb_demux.h: DVB kernel demux API
3 *
4 * Copyright (C) 2000-2001 Marcus Metzler & Ralph Metzler
5 * for convergence integrated media GmbH
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * as published by the Free Software Foundation; either version 2.1
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 */
18
19#ifndef _DVB_DEMUX_H_
20#define _DVB_DEMUX_H_
21
22#include <linux/time.h>
23#include <linux/timer.h>
24#include <linux/spinlock.h>
25#include <linux/mutex.h>
26
27#include <media/demux.h>
28
29/**
30 * enum dvb_dmx_filter_type - type of demux feed.
31 *
32 * @DMX_TYPE_TS: feed is in TS mode.
33 * @DMX_TYPE_SEC: feed is in Section mode.
34 */
35enum dvb_dmx_filter_type {
36 DMX_TYPE_TS,
37 DMX_TYPE_SEC,
38};
39
40/**
41 * enum dvb_dmx_state - state machine for a demux filter.
42 *
43 * @DMX_STATE_FREE: indicates that the filter is freed.
44 * @DMX_STATE_ALLOCATED: indicates that the filter was allocated
45 * to be used.
46 * @DMX_STATE_READY: indicates that the filter is ready
47 * to be used.
48 * @DMX_STATE_GO: indicates that the filter is running.
49 */
50enum dvb_dmx_state {
51 DMX_STATE_FREE,
52 DMX_STATE_ALLOCATED,
53 DMX_STATE_READY,
54 DMX_STATE_GO,
55};
56
57#define DVB_DEMUX_MASK_MAX 18
58
59#define MAX_PID 0x1fff
60
61#define SPEED_PKTS_INTERVAL 50000
62
63/**
64 * struct dvb_demux_filter - Describes a DVB demux section filter.
65 *
66 * @filter: Section filter as defined by &struct dmx_section_filter.
67 * @maskandmode: logical ``and`` bit mask.
68 * @maskandnotmode: logical ``and not`` bit mask.
69 * @doneq: flag that indicates when a filter is ready.
70 * @next: pointer to the next section filter.
71 * @feed: &struct dvb_demux_feed pointer.
72 * @index: index of the used demux filter.
73 * @state: state of the filter as described by &enum dvb_dmx_state.
74 * @type: type of the filter as described
75 * by &enum dvb_dmx_filter_type.
76 */
77
78struct dvb_demux_filter {
79 struct dmx_section_filter filter;
80 u8 maskandmode[DMX_MAX_FILTER_SIZE];
81 u8 maskandnotmode[DMX_MAX_FILTER_SIZE];
82 bool doneq;
83
84 struct dvb_demux_filter *next;
85 struct dvb_demux_feed *feed;
86 int index;
87 enum dvb_dmx_state state;
88 enum dvb_dmx_filter_type type;
89
90 /* private: used only by av7110 */
91 u16 hw_handle;
92};
93
94/**
95 * struct dvb_demux_feed - describes a DVB field
96 *
97 * @feed: a union describing a digital TV feed.
98 * Depending on the feed type, it can be either
99 * @feed.ts or @feed.sec.
100 * @feed.ts: a &struct dmx_ts_feed pointer.
101 * For TS feed only.
102 * @feed.sec: a &struct dmx_section_feed pointer.
103 * For section feed only.
104 * @cb: a union describing digital TV callbacks.
105 * Depending on the feed type, it can be either
106 * @cb.ts or @cb.sec.
107 * @cb.ts: a dmx_ts_cb() calback function pointer.
108 * For TS feed only.
109 * @cb.sec: a dmx_section_cb() callback function pointer.
110 * For section feed only.
111 * @demux: pointer to &struct dvb_demux.
112 * @priv: private data that can optionally be used by a DVB driver.
113 * @type: type of the filter, as defined by &enum dvb_dmx_filter_type.
114 * @state: state of the filter as defined by &enum dvb_dmx_state.
115 * @pid: PID to be filtered.
116 * @timeout: feed timeout.
117 * @filter: pointer to &struct dvb_demux_filter.
118 * @ts_type: type of TS, as defined by &enum ts_filter_type.
119 * @pes_type: type of PES, as defined by &enum dmx_ts_pes.
120 * @cc: MPEG-TS packet continuity counter
121 * @pusi_seen: if true, indicates that a discontinuity was detected.
122 * it is used to prevent feeding of garbage from previous section.
123 * @peslen: length of the PES (Packet Elementary Stream).
124 * @list_head: head for the list of digital TV demux feeds.
125 * @index: a unique index for each feed. Can be used as hardware
126 * pid filter index.
127 */
128struct dvb_demux_feed {
129 union {
130 struct dmx_ts_feed ts;
131 struct dmx_section_feed sec;
132 } feed;
133
134 union {
135 dmx_ts_cb ts;
136 dmx_section_cb sec;
137 } cb;
138
139 struct dvb_demux *demux;
140 void *priv;
141 enum dvb_dmx_filter_type type;
142 enum dvb_dmx_state state;
143 u16 pid;
144
145 ktime_t timeout;
146 struct dvb_demux_filter *filter;
147
148 enum ts_filter_type ts_type;
149 enum dmx_ts_pes pes_type;
150
151 int cc;
152 bool pusi_seen;
153
154 u16 peslen;
155
156 struct list_head list_head;
157 unsigned int index;
158};
159
160/**
161 * struct dvb_demux - represents a digital TV demux
162 * @dmx: embedded &struct dmx_demux with demux capabilities
163 * and callbacks.
164 * @priv: private data that can optionally be used by
165 * a DVB driver.
166 * @filternum: maximum amount of DVB filters.
167 * @feednum: maximum amount of DVB feeds.
168 * @start_feed: callback routine to be called in order to start
169 * a DVB feed.
170 * @stop_feed: callback routine to be called in order to stop
171 * a DVB feed.
172 * @write_to_decoder: callback routine to be called if the feed is TS and
173 * it is routed to an A/V decoder, when a new TS packet
174 * is received.
175 * Used only on av7110-av.c.
176 * @check_crc32: callback routine to check CRC. If not initialized,
177 * dvb_demux will use an internal one.
178 * @memcopy: callback routine to memcopy received data.
179 * If not initialized, dvb_demux will default to memcpy().
180 * @users: counter for the number of demux opened file descriptors.
181 * Currently, it is limited to 10 users.
182 * @filter: pointer to &struct dvb_demux_filter.
183 * @feed: pointer to &struct dvb_demux_feed.
184 * @frontend_list: &struct list_head with frontends used by the demux.
185 * @pesfilter: array of &struct dvb_demux_feed with the PES types
186 * that will be filtered.
187 * @pids: list of filtered program IDs.
188 * @feed_list: &struct list_head with feeds.
189 * @tsbuf: temporary buffer used internally to store TS packets.
190 * @tsbufp: temporary buffer index used internally.
191 * @mutex: pointer to &struct mutex used to protect feed set
192 * logic.
193 * @lock: pointer to &spinlock_t, used to protect buffer handling.
194 * @cnt_storage: buffer used for TS/TEI continuity check.
195 * @speed_last_time: &ktime_t used for TS speed check.
196 * @speed_pkts_cnt: packets count used for TS speed check.
197 */
198struct dvb_demux {
199 struct dmx_demux dmx;
200 void *priv;
201 int filternum;
202 int feednum;
203 int (*start_feed)(struct dvb_demux_feed *feed);
204 int (*stop_feed)(struct dvb_demux_feed *feed);
205 int (*write_to_decoder)(struct dvb_demux_feed *feed,
206 const u8 *buf, size_t len);
207 u32 (*check_crc32)(struct dvb_demux_feed *feed,
208 const u8 *buf, size_t len);
209 void (*memcopy)(struct dvb_demux_feed *feed, u8 *dst,
210 const u8 *src, size_t len);
211
212 int users;
213#define MAX_DVB_DEMUX_USERS 10
214 struct dvb_demux_filter *filter;
215 struct dvb_demux_feed *feed;
216
217 struct list_head frontend_list;
218
219 struct dvb_demux_feed *pesfilter[DMX_PES_OTHER];
220 u16 pids[DMX_PES_OTHER];
221
222#define DMX_MAX_PID 0x2000
223 struct list_head feed_list;
224 u8 tsbuf[204];
225 int tsbufp;
226
227 struct mutex mutex;
228 spinlock_t lock;
229
230 uint8_t *cnt_storage; /* for TS continuity check */
231
232 ktime_t speed_last_time; /* for TS speed check */
233 uint32_t speed_pkts_cnt; /* for TS speed check */
234
235 /* private: used only on av7110 */
236 int playing;
237 int recording;
238};
239
240/**
241 * dvb_dmx_init - initialize a digital TV demux struct.
242 *
243 * @demux: &struct dvb_demux to be initialized.
244 *
245 * Before being able to register a digital TV demux struct, drivers
246 * should call this routine. On its typical usage, some fields should
247 * be initialized at the driver before calling it.
248 *
249 * A typical usecase is::
250 *
251 * dvb->demux.dmx.capabilities =
252 * DMX_TS_FILTERING | DMX_SECTION_FILTERING |
253 * DMX_MEMORY_BASED_FILTERING;
254 * dvb->demux.priv = dvb;
255 * dvb->demux.filternum = 256;
256 * dvb->demux.feednum = 256;
257 * dvb->demux.start_feed = driver_start_feed;
258 * dvb->demux.stop_feed = driver_stop_feed;
259 * ret = dvb_dmx_init(&dvb->demux);
260 * if (ret < 0)
261 * return ret;
262 */
263int dvb_dmx_init(struct dvb_demux *demux);
264
265/**
266 * dvb_dmx_release - releases a digital TV demux internal buffers.
267 *
268 * @demux: &struct dvb_demux to be released.
269 *
270 * The DVB core internally allocates data at @demux. This routine
271 * releases those data. Please notice that the struct itelf is not
272 * released, as it can be embedded on other structs.
273 */
274void dvb_dmx_release(struct dvb_demux *demux);
275
276/**
277 * dvb_dmx_swfilter_packets - use dvb software filter for a buffer with
278 * multiple MPEG-TS packets with 188 bytes each.
279 *
280 * @demux: pointer to &struct dvb_demux
281 * @buf: buffer with data to be filtered
282 * @count: number of MPEG-TS packets with size of 188.
283 *
284 * The routine will discard a DVB packet that don't start with 0x47.
285 *
286 * Use this routine if the DVB demux fills MPEG-TS buffers that are
287 * already aligned.
288 *
289 * NOTE: The @buf size should have size equal to ``count * 188``.
290 */
291void dvb_dmx_swfilter_packets(struct dvb_demux *demux, const u8 *buf,
292 size_t count);
293
294/**
295 * dvb_dmx_swfilter - use dvb software filter for a buffer with
296 * multiple MPEG-TS packets with 188 bytes each.
297 *
298 * @demux: pointer to &struct dvb_demux
299 * @buf: buffer with data to be filtered
300 * @count: number of MPEG-TS packets with size of 188.
301 *
302 * If a DVB packet doesn't start with 0x47, it will seek for the first
303 * byte that starts with 0x47.
304 *
305 * Use this routine if the DVB demux fill buffers that may not start with
306 * a packet start mark (0x47).
307 *
308 * NOTE: The @buf size should have size equal to ``count * 188``.
309 */
310void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count);
311
312/**
313 * dvb_dmx_swfilter_204 - use dvb software filter for a buffer with
314 * multiple MPEG-TS packets with 204 bytes each.
315 *
316 * @demux: pointer to &struct dvb_demux
317 * @buf: buffer with data to be filtered
318 * @count: number of MPEG-TS packets with size of 204.
319 *
320 * If a DVB packet doesn't start with 0x47, it will seek for the first
321 * byte that starts with 0x47.
322 *
323 * Use this routine if the DVB demux fill buffers that may not start with
324 * a packet start mark (0x47).
325 *
326 * NOTE: The @buf size should have size equal to ``count * 204``.
327 */
328void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf,
329 size_t count);
330
331/**
332 * dvb_dmx_swfilter_raw - make the raw data available to userspace without
333 * filtering
334 *
335 * @demux: pointer to &struct dvb_demux
336 * @buf: buffer with data
337 * @count: number of packets to be passed. The actual size of each packet
338 * depends on the &dvb_demux->feed->cb.ts logic.
339 *
340 * Use it if the driver needs to deliver the raw payload to userspace without
341 * passing through the kernel demux. That is meant to support some
342 * delivery systems that aren't based on MPEG-TS.
343 *
344 * This function relies on &dvb_demux->feed->cb.ts to actually handle the
345 * buffer.
346 */
347void dvb_dmx_swfilter_raw(struct dvb_demux *demux, const u8 *buf,
348 size_t count);
349
350#endif /* _DVB_DEMUX_H_ */
diff --git a/include/media/dvb_frontend.h b/include/media/dvb_frontend.h
new file mode 100644
index 000000000000..331c8269c00e
--- /dev/null
+++ b/include/media/dvb_frontend.h
@@ -0,0 +1,795 @@
1/*
2 * dvb_frontend.h
3 *
4 * The Digital TV Frontend kABI defines a driver-internal interface for
5 * registering low-level, hardware specific driver to a hardware independent
6 * frontend layer.
7 *
8 * Copyright (C) 2001 convergence integrated media GmbH
9 * Copyright (C) 2004 convergence GmbH
10 *
11 * Written by Ralph Metzler
12 * Overhauled by Holger Waechtler
13 * Kernel I2C stuff by Michael Hunold <hunold@convergence.de>
14 *
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU Lesser General Public License
17 * as published by the Free Software Foundation; either version 2.1
18 * of the License, or (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25
26 * You should have received a copy of the GNU Lesser General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 *
30 */
31
32#ifndef _DVB_FRONTEND_H_
33#define _DVB_FRONTEND_H_
34
35#include <linux/types.h>
36#include <linux/sched.h>
37#include <linux/ioctl.h>
38#include <linux/i2c.h>
39#include <linux/module.h>
40#include <linux/errno.h>
41#include <linux/delay.h>
42#include <linux/mutex.h>
43#include <linux/slab.h>
44
45#include <linux/dvb/frontend.h>
46
47#include <media/dvbdev.h>
48
49/*
50 * Maximum number of Delivery systems per frontend. It
51 * should be smaller or equal to 32
52 */
53#define MAX_DELSYS 8
54
55/**
56 * struct dvb_frontend_tune_settings - parameters to adjust frontend tuning
57 *
58 * @min_delay_ms: minimum delay for tuning, in ms
59 * @step_size: step size between two consecutive frequencies
60 * @max_drift: maximum drift
61 *
62 * NOTE: step_size is in Hz, for terrestrial/cable or kHz for satellite
63 */
64struct dvb_frontend_tune_settings {
65 int min_delay_ms;
66 int step_size;
67 int max_drift;
68};
69
70struct dvb_frontend;
71
72/**
73 * struct dvb_tuner_info - Frontend name and min/max ranges/bandwidths
74 *
75 * @name: name of the Frontend
76 * @frequency_min: minimal frequency supported
77 * @frequency_max: maximum frequency supported
78 * @frequency_step: frequency step
79 * @bandwidth_min: minimal frontend bandwidth supported
80 * @bandwidth_max: maximum frontend bandwidth supported
81 * @bandwidth_step: frontend bandwidth step
82 *
83 * NOTE: frequency parameters are in Hz, for terrestrial/cable or kHz for
84 * satellite.
85 */
86struct dvb_tuner_info {
87 char name[128];
88
89 u32 frequency_min;
90 u32 frequency_max;
91 u32 frequency_step;
92
93 u32 bandwidth_min;
94 u32 bandwidth_max;
95 u32 bandwidth_step;
96};
97
98/**
99 * struct analog_parameters - Parameters to tune into an analog/radio channel
100 *
101 * @frequency: Frequency used by analog TV tuner (either in 62.5 kHz step,
102 * for TV, or 62.5 Hz for radio)
103 * @mode: Tuner mode, as defined on enum v4l2_tuner_type
104 * @audmode: Audio mode as defined for the rxsubchans field at videodev2.h,
105 * e. g. V4L2_TUNER_MODE_*
106 * @std: TV standard bitmap as defined at videodev2.h, e. g. V4L2_STD_*
107 *
108 * Hybrid tuners should be supported by both V4L2 and DVB APIs. This
109 * struct contains the data that are used by the V4L2 side. To avoid
110 * dependencies from V4L2 headers, all enums here are declared as integers.
111 */
112struct analog_parameters {
113 unsigned int frequency;
114 unsigned int mode;
115 unsigned int audmode;
116 u64 std;
117};
118
119/**
120 * enum dvbfe_algo - defines the algorithm used to tune into a channel
121 *
122 * @DVBFE_ALGO_HW: Hardware Algorithm -
123 * Devices that support this algorithm do everything in hardware
124 * and no software support is needed to handle them.
125 * Requesting these devices to LOCK is the only thing required,
126 * device is supposed to do everything in the hardware.
127 *
128 * @DVBFE_ALGO_SW: Software Algorithm -
129 * These are dumb devices, that require software to do everything
130 *
131 * @DVBFE_ALGO_CUSTOM: Customizable Agorithm -
132 * Devices having this algorithm can be customized to have specific
133 * algorithms in the frontend driver, rather than simply doing a
134 * software zig-zag. In this case the zigzag maybe hardware assisted
135 * or it maybe completely done in hardware. In all cases, usage of
136 * this algorithm, in conjunction with the search and track
137 * callbacks, utilizes the driver specific algorithm.
138 *
139 * @DVBFE_ALGO_RECOVERY: Recovery Algorithm -
140 * These devices have AUTO recovery capabilities from LOCK failure
141 */
142enum dvbfe_algo {
143 DVBFE_ALGO_HW = (1 << 0),
144 DVBFE_ALGO_SW = (1 << 1),
145 DVBFE_ALGO_CUSTOM = (1 << 2),
146 DVBFE_ALGO_RECOVERY = (1 << 31)
147};
148
149/**
150 * enum dvbfe_search - search callback possible return status
151 *
152 * @DVBFE_ALGO_SEARCH_SUCCESS:
153 * The frontend search algorithm completed and returned successfully
154 *
155 * @DVBFE_ALGO_SEARCH_ASLEEP:
156 * The frontend search algorithm is sleeping
157 *
158 * @DVBFE_ALGO_SEARCH_FAILED:
159 * The frontend search for a signal failed
160 *
161 * @DVBFE_ALGO_SEARCH_INVALID:
162 * The frontend search algorith was probably supplied with invalid
163 * parameters and the search is an invalid one
164 *
165 * @DVBFE_ALGO_SEARCH_ERROR:
166 * The frontend search algorithm failed due to some error
167 *
168 * @DVBFE_ALGO_SEARCH_AGAIN:
169 * The frontend search algorithm was requested to search again
170 */
171enum dvbfe_search {
172 DVBFE_ALGO_SEARCH_SUCCESS = (1 << 0),
173 DVBFE_ALGO_SEARCH_ASLEEP = (1 << 1),
174 DVBFE_ALGO_SEARCH_FAILED = (1 << 2),
175 DVBFE_ALGO_SEARCH_INVALID = (1 << 3),
176 DVBFE_ALGO_SEARCH_AGAIN = (1 << 4),
177 DVBFE_ALGO_SEARCH_ERROR = (1 << 31),
178};
179
180/**
181 * struct dvb_tuner_ops - Tuner information and callbacks
182 *
183 * @info: embedded &struct dvb_tuner_info with tuner properties
184 * @release: callback function called when frontend is detached.
185 * drivers should free any allocated memory.
186 * @init: callback function used to initialize the tuner device.
187 * @sleep: callback function used to put the tuner to sleep.
188 * @suspend: callback function used to inform that the Kernel will
189 * suspend.
190 * @resume: callback function used to inform that the Kernel is
191 * resuming from suspend.
192 * @set_params: callback function used to inform the tuner to tune
193 * into a digital TV channel. The properties to be used
194 * are stored at &struct dvb_frontend.dtv_property_cache.
195 * The tuner demod can change the parameters to reflect
196 * the changes needed for the channel to be tuned, and
197 * update statistics. This is the recommended way to set
198 * the tuner parameters and should be used on newer
199 * drivers.
200 * @set_analog_params: callback function used to tune into an analog TV
201 * channel on hybrid tuners. It passes @analog_parameters
202 * to the driver.
203 * @set_config: callback function used to send some tuner-specific
204 * parameters.
205 * @get_frequency: get the actual tuned frequency
206 * @get_bandwidth: get the bandwitdh used by the low pass filters
207 * @get_if_frequency: get the Intermediate Frequency, in Hz. For baseband,
208 * should return 0.
209 * @get_status: returns the frontend lock status
210 * @get_rf_strength: returns the RF signal strength. Used mostly to support
211 * analog TV and radio. Digital TV should report, instead,
212 * via DVBv5 API (&struct dvb_frontend.dtv_property_cache).
213 * @get_afc: Used only by analog TV core. Reports the frequency
214 * drift due to AFC.
215 * @calc_regs: callback function used to pass register data settings
216 * for simple tuners. Shouldn't be used on newer drivers.
217 * @set_frequency: Set a new frequency. Shouldn't be used on newer drivers.
218 * @set_bandwidth: Set a new frequency. Shouldn't be used on newer drivers.
219 *
220 * NOTE: frequencies used on @get_frequency and @set_frequency are in Hz for
221 * terrestrial/cable or kHz for satellite.
222 *
223 */
224struct dvb_tuner_ops {
225
226 struct dvb_tuner_info info;
227
228 void (*release)(struct dvb_frontend *fe);
229 int (*init)(struct dvb_frontend *fe);
230 int (*sleep)(struct dvb_frontend *fe);
231 int (*suspend)(struct dvb_frontend *fe);
232 int (*resume)(struct dvb_frontend *fe);
233
234 /* This is the recomended way to set the tuner */
235 int (*set_params)(struct dvb_frontend *fe);
236 int (*set_analog_params)(struct dvb_frontend *fe, struct analog_parameters *p);
237
238 int (*set_config)(struct dvb_frontend *fe, void *priv_cfg);
239
240 int (*get_frequency)(struct dvb_frontend *fe, u32 *frequency);
241 int (*get_bandwidth)(struct dvb_frontend *fe, u32 *bandwidth);
242 int (*get_if_frequency)(struct dvb_frontend *fe, u32 *frequency);
243
244#define TUNER_STATUS_LOCKED 1
245#define TUNER_STATUS_STEREO 2
246 int (*get_status)(struct dvb_frontend *fe, u32 *status);
247 int (*get_rf_strength)(struct dvb_frontend *fe, u16 *strength);
248 int (*get_afc)(struct dvb_frontend *fe, s32 *afc);
249
250 /*
251 * This is support for demods like the mt352 - fills out the supplied
252 * buffer with what to write.
253 *
254 * Don't use on newer drivers.
255 */
256 int (*calc_regs)(struct dvb_frontend *fe, u8 *buf, int buf_len);
257
258 /*
259 * These are provided separately from set_params in order to
260 * facilitate silicon tuners which require sophisticated tuning loops,
261 * controlling each parameter separately.
262 *
263 * Don't use on newer drivers.
264 */
265 int (*set_frequency)(struct dvb_frontend *fe, u32 frequency);
266 int (*set_bandwidth)(struct dvb_frontend *fe, u32 bandwidth);
267};
268
269/**
270 * struct analog_demod_info - Information struct for analog TV part of the demod
271 *
272 * @name: Name of the analog TV demodulator
273 */
274struct analog_demod_info {
275 char *name;
276};
277
278/**
279 * struct analog_demod_ops - Demodulation information and callbacks for
280 * analog TV and radio
281 *
282 * @info: pointer to struct analog_demod_info
283 * @set_params: callback function used to inform the demod to set the
284 * demodulator parameters needed to decode an analog or
285 * radio channel. The properties are passed via
286 * &struct analog_params.
287 * @has_signal: returns 0xffff if has signal, or 0 if it doesn't.
288 * @get_afc: Used only by analog TV core. Reports the frequency
289 * drift due to AFC.
290 * @tuner_status: callback function that returns tuner status bits, e. g.
291 * %TUNER_STATUS_LOCKED and %TUNER_STATUS_STEREO.
292 * @standby: set the tuner to standby mode.
293 * @release: callback function called when frontend is detached.
294 * drivers should free any allocated memory.
295 * @i2c_gate_ctrl: controls the I2C gate. Newer drivers should use I2C
296 * mux support instead.
297 * @set_config: callback function used to send some tuner-specific
298 * parameters.
299 */
300struct analog_demod_ops {
301
302 struct analog_demod_info info;
303
304 void (*set_params)(struct dvb_frontend *fe,
305 struct analog_parameters *params);
306 int (*has_signal)(struct dvb_frontend *fe, u16 *signal);
307 int (*get_afc)(struct dvb_frontend *fe, s32 *afc);
308 void (*tuner_status)(struct dvb_frontend *fe);
309 void (*standby)(struct dvb_frontend *fe);
310 void (*release)(struct dvb_frontend *fe);
311 int (*i2c_gate_ctrl)(struct dvb_frontend *fe, int enable);
312
313 /** This is to allow setting tuner-specific configuration */
314 int (*set_config)(struct dvb_frontend *fe, void *priv_cfg);
315};
316
317struct dtv_frontend_properties;
318
319
320/**
321 * struct dvb_frontend_ops - Demodulation information and callbacks for
322 * ditialt TV
323 *
324 * @info: embedded &struct dvb_tuner_info with tuner properties
325 * @delsys: Delivery systems supported by the frontend
326 * @detach: callback function called when frontend is detached.
327 * drivers should clean up, but not yet free the &struct
328 * dvb_frontend allocation.
329 * @release: callback function called when frontend is ready to be
330 * freed.
331 * drivers should free any allocated memory.
332 * @release_sec: callback function requesting that the Satelite Equipment
333 * Control (SEC) driver to release and free any memory
334 * allocated by the driver.
335 * @init: callback function used to initialize the tuner device.
336 * @sleep: callback function used to put the tuner to sleep.
337 * @write: callback function used by some demod legacy drivers to
338 * allow other drivers to write data into their registers.
339 * Should not be used on new drivers.
340 * @tune: callback function used by demod drivers that use
341 * @DVBFE_ALGO_HW to tune into a frequency.
342 * @get_frontend_algo: returns the desired hardware algorithm.
343 * @set_frontend: callback function used to inform the demod to set the
344 * parameters for demodulating a digital TV channel.
345 * The properties to be used are stored at &struct
346 * dvb_frontend.dtv_property_cache. The demod can change
347 * the parameters to reflect the changes needed for the
348 * channel to be decoded, and update statistics.
349 * @get_tune_settings: callback function
350 * @get_frontend: callback function used to inform the parameters
351 * actuall in use. The properties to be used are stored at
352 * &struct dvb_frontend.dtv_property_cache and update
353 * statistics. Please notice that it should not return
354 * an error code if the statistics are not available
355 * because the demog is not locked.
356 * @read_status: returns the locking status of the frontend.
357 * @read_ber: legacy callback function to return the bit error rate.
358 * Newer drivers should provide such info via DVBv5 API,
359 * e. g. @set_frontend;/@get_frontend, implementing this
360 * callback only if DVBv3 API compatibility is wanted.
361 * @read_signal_strength: legacy callback function to return the signal
362 * strength. Newer drivers should provide such info via
363 * DVBv5 API, e. g. @set_frontend/@get_frontend,
364 * implementing this callback only if DVBv3 API
365 * compatibility is wanted.
366 * @read_snr: legacy callback function to return the Signal/Noise
367 * rate. Newer drivers should provide such info via
368 * DVBv5 API, e. g. @set_frontend/@get_frontend,
369 * implementing this callback only if DVBv3 API
370 * compatibility is wanted.
371 * @read_ucblocks: legacy callback function to return the Uncorrected Error
372 * Blocks. Newer drivers should provide such info via
373 * DVBv5 API, e. g. @set_frontend/@get_frontend,
374 * implementing this callback only if DVBv3 API
375 * compatibility is wanted.
376 * @diseqc_reset_overload: callback function to implement the
377 * FE_DISEQC_RESET_OVERLOAD() ioctl (only Satellite)
378 * @diseqc_send_master_cmd: callback function to implement the
379 * FE_DISEQC_SEND_MASTER_CMD() ioctl (only Satellite).
380 * @diseqc_recv_slave_reply: callback function to implement the
381 * FE_DISEQC_RECV_SLAVE_REPLY() ioctl (only Satellite)
382 * @diseqc_send_burst: callback function to implement the
383 * FE_DISEQC_SEND_BURST() ioctl (only Satellite).
384 * @set_tone: callback function to implement the
385 * FE_SET_TONE() ioctl (only Satellite).
386 * @set_voltage: callback function to implement the
387 * FE_SET_VOLTAGE() ioctl (only Satellite).
388 * @enable_high_lnb_voltage: callback function to implement the
389 * FE_ENABLE_HIGH_LNB_VOLTAGE() ioctl (only Satellite).
390 * @dishnetwork_send_legacy_command: callback function to implement the
391 * FE_DISHNETWORK_SEND_LEGACY_CMD() ioctl (only Satellite).
392 * Drivers should not use this, except when the DVB
393 * core emulation fails to provide proper support (e.g.
394 * if @set_voltage takes more than 8ms to work), and
395 * when backward compatibility with this legacy API is
396 * required.
397 * @i2c_gate_ctrl: controls the I2C gate. Newer drivers should use I2C
398 * mux support instead.
399 * @ts_bus_ctrl: callback function used to take control of the TS bus.
400 * @set_lna: callback function to power on/off/auto the LNA.
401 * @search: callback function used on some custom algo search algos.
402 * @tuner_ops: pointer to &struct dvb_tuner_ops
403 * @analog_ops: pointer to &struct analog_demod_ops
404 */
405struct dvb_frontend_ops {
406 struct dvb_frontend_info info;
407
408 u8 delsys[MAX_DELSYS];
409
410 void (*detach)(struct dvb_frontend *fe);
411 void (*release)(struct dvb_frontend* fe);
412 void (*release_sec)(struct dvb_frontend* fe);
413
414 int (*init)(struct dvb_frontend* fe);
415 int (*sleep)(struct dvb_frontend* fe);
416
417 int (*write)(struct dvb_frontend* fe, const u8 buf[], int len);
418
419 /* if this is set, it overrides the default swzigzag */
420 int (*tune)(struct dvb_frontend* fe,
421 bool re_tune,
422 unsigned int mode_flags,
423 unsigned int *delay,
424 enum fe_status *status);
425
426 /* get frontend tuning algorithm from the module */
427 enum dvbfe_algo (*get_frontend_algo)(struct dvb_frontend *fe);
428
429 /* these two are only used for the swzigzag code */
430 int (*set_frontend)(struct dvb_frontend *fe);
431 int (*get_tune_settings)(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* settings);
432
433 int (*get_frontend)(struct dvb_frontend *fe,
434 struct dtv_frontend_properties *props);
435
436 int (*read_status)(struct dvb_frontend *fe, enum fe_status *status);
437 int (*read_ber)(struct dvb_frontend* fe, u32* ber);
438 int (*read_signal_strength)(struct dvb_frontend* fe, u16* strength);
439 int (*read_snr)(struct dvb_frontend* fe, u16* snr);
440 int (*read_ucblocks)(struct dvb_frontend* fe, u32* ucblocks);
441
442 int (*diseqc_reset_overload)(struct dvb_frontend* fe);
443 int (*diseqc_send_master_cmd)(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd);
444 int (*diseqc_recv_slave_reply)(struct dvb_frontend* fe, struct dvb_diseqc_slave_reply* reply);
445 int (*diseqc_send_burst)(struct dvb_frontend *fe,
446 enum fe_sec_mini_cmd minicmd);
447 int (*set_tone)(struct dvb_frontend *fe, enum fe_sec_tone_mode tone);
448 int (*set_voltage)(struct dvb_frontend *fe,
449 enum fe_sec_voltage voltage);
450 int (*enable_high_lnb_voltage)(struct dvb_frontend* fe, long arg);
451 int (*dishnetwork_send_legacy_command)(struct dvb_frontend* fe, unsigned long cmd);
452 int (*i2c_gate_ctrl)(struct dvb_frontend* fe, int enable);
453 int (*ts_bus_ctrl)(struct dvb_frontend* fe, int acquire);
454 int (*set_lna)(struct dvb_frontend *);
455
456 /*
457 * These callbacks are for devices that implement their own
458 * tuning algorithms, rather than a simple swzigzag
459 */
460 enum dvbfe_search (*search)(struct dvb_frontend *fe);
461
462 struct dvb_tuner_ops tuner_ops;
463 struct analog_demod_ops analog_ops;
464};
465
466#ifdef __DVB_CORE__
467#define MAX_EVENT 8
468
469/* Used only internally at dvb_frontend.c */
470struct dvb_fe_events {
471 struct dvb_frontend_event events[MAX_EVENT];
472 int eventw;
473 int eventr;
474 int overflow;
475 wait_queue_head_t wait_queue;
476 struct mutex mtx;
477};
478#endif
479
480/**
481 * struct dtv_frontend_properties - contains a list of properties that are
482 * specific to a digital TV standard.
483 *
484 * @frequency: frequency in Hz for terrestrial/cable or in kHz for
485 * Satellite
486 * @modulation: Frontend modulation type
487 * @voltage: SEC voltage (only Satellite)
488 * @sectone: SEC tone mode (only Satellite)
489 * @inversion: Spectral inversion
490 * @fec_inner: Forward error correction inner Code Rate
491 * @transmission_mode: Transmission Mode
492 * @bandwidth_hz: Bandwidth, in Hz. A zero value means that userspace
493 * wants to autodetect.
494 * @guard_interval: Guard Interval
495 * @hierarchy: Hierarchy
496 * @symbol_rate: Symbol Rate
497 * @code_rate_HP: high priority stream code rate
498 * @code_rate_LP: low priority stream code rate
499 * @pilot: Enable/disable/autodetect pilot tones
500 * @rolloff: Rolloff factor (alpha)
501 * @delivery_system: FE delivery system (e. g. digital TV standard)
502 * @interleaving: interleaving
503 * @isdbt_partial_reception: ISDB-T partial reception (only ISDB standard)
504 * @isdbt_sb_mode: ISDB-T Sound Broadcast (SB) mode (only ISDB standard)
505 * @isdbt_sb_subchannel: ISDB-T SB subchannel (only ISDB standard)
506 * @isdbt_sb_segment_idx: ISDB-T SB segment index (only ISDB standard)
507 * @isdbt_sb_segment_count: ISDB-T SB segment count (only ISDB standard)
508 * @isdbt_layer_enabled: ISDB Layer enabled (only ISDB standard)
509 * @layer: ISDB per-layer data (only ISDB standard)
510 * @layer.segment_count: Segment Count;
511 * @layer.fec: per layer code rate;
512 * @layer.modulation: per layer modulation;
513 * @layer.interleaving: per layer interleaving.
514 * @stream_id: If different than zero, enable substream filtering, if
515 * hardware supports (DVB-S2 and DVB-T2).
516 * @scrambling_sequence_index: Carries the index of the DVB-S2 physical layer
517 * scrambling sequence.
518 * @atscmh_fic_ver: Version number of the FIC (Fast Information Channel)
519 * signaling data (only ATSC-M/H)
520 * @atscmh_parade_id: Parade identification number (only ATSC-M/H)
521 * @atscmh_nog: Number of MH groups per MH subframe for a designated
522 * parade (only ATSC-M/H)
523 * @atscmh_tnog: Total number of MH groups including all MH groups
524 * belonging to all MH parades in one MH subframe
525 * (only ATSC-M/H)
526 * @atscmh_sgn: Start group number (only ATSC-M/H)
527 * @atscmh_prc: Parade repetition cycle (only ATSC-M/H)
528 * @atscmh_rs_frame_mode: Reed Solomon (RS) frame mode (only ATSC-M/H)
529 * @atscmh_rs_frame_ensemble: RS frame ensemble (only ATSC-M/H)
530 * @atscmh_rs_code_mode_pri: RS code mode pri (only ATSC-M/H)
531 * @atscmh_rs_code_mode_sec: RS code mode sec (only ATSC-M/H)
532 * @atscmh_sccc_block_mode: Series Concatenated Convolutional Code (SCCC)
533 * Block Mode (only ATSC-M/H)
534 * @atscmh_sccc_code_mode_a: SCCC code mode A (only ATSC-M/H)
535 * @atscmh_sccc_code_mode_b: SCCC code mode B (only ATSC-M/H)
536 * @atscmh_sccc_code_mode_c: SCCC code mode C (only ATSC-M/H)
537 * @atscmh_sccc_code_mode_d: SCCC code mode D (only ATSC-M/H)
538 * @lna: Power ON/OFF/AUTO the Linear Now-noise Amplifier (LNA)
539 * @strength: DVBv5 API statistics: Signal Strength
540 * @cnr: DVBv5 API statistics: Signal to Noise ratio of the
541 * (main) carrier
542 * @pre_bit_error: DVBv5 API statistics: pre-Viterbi bit error count
543 * @pre_bit_count: DVBv5 API statistics: pre-Viterbi bit count
544 * @post_bit_error: DVBv5 API statistics: post-Viterbi bit error count
545 * @post_bit_count: DVBv5 API statistics: post-Viterbi bit count
546 * @block_error: DVBv5 API statistics: block error count
547 * @block_count: DVBv5 API statistics: block count
548 *
549 * NOTE: derivated statistics like Uncorrected Error blocks (UCE) are
550 * calculated on userspace.
551 *
552 * Only a subset of the properties are needed for a given delivery system.
553 * For more info, consult the media_api.html with the documentation of the
554 * Userspace API.
555 */
556struct dtv_frontend_properties {
557 u32 frequency;
558 enum fe_modulation modulation;
559
560 enum fe_sec_voltage voltage;
561 enum fe_sec_tone_mode sectone;
562 enum fe_spectral_inversion inversion;
563 enum fe_code_rate fec_inner;
564 enum fe_transmit_mode transmission_mode;
565 u32 bandwidth_hz; /* 0 = AUTO */
566 enum fe_guard_interval guard_interval;
567 enum fe_hierarchy hierarchy;
568 u32 symbol_rate;
569 enum fe_code_rate code_rate_HP;
570 enum fe_code_rate code_rate_LP;
571
572 enum fe_pilot pilot;
573 enum fe_rolloff rolloff;
574
575 enum fe_delivery_system delivery_system;
576
577 enum fe_interleaving interleaving;
578
579 /* ISDB-T specifics */
580 u8 isdbt_partial_reception;
581 u8 isdbt_sb_mode;
582 u8 isdbt_sb_subchannel;
583 u32 isdbt_sb_segment_idx;
584 u32 isdbt_sb_segment_count;
585 u8 isdbt_layer_enabled;
586 struct {
587 u8 segment_count;
588 enum fe_code_rate fec;
589 enum fe_modulation modulation;
590 u8 interleaving;
591 } layer[3];
592
593 /* Multistream specifics */
594 u32 stream_id;
595
596 /* Physical Layer Scrambling specifics */
597 u32 scrambling_sequence_index;
598
599 /* ATSC-MH specifics */
600 u8 atscmh_fic_ver;
601 u8 atscmh_parade_id;
602 u8 atscmh_nog;
603 u8 atscmh_tnog;
604 u8 atscmh_sgn;
605 u8 atscmh_prc;
606
607 u8 atscmh_rs_frame_mode;
608 u8 atscmh_rs_frame_ensemble;
609 u8 atscmh_rs_code_mode_pri;
610 u8 atscmh_rs_code_mode_sec;
611 u8 atscmh_sccc_block_mode;
612 u8 atscmh_sccc_code_mode_a;
613 u8 atscmh_sccc_code_mode_b;
614 u8 atscmh_sccc_code_mode_c;
615 u8 atscmh_sccc_code_mode_d;
616
617 u32 lna;
618
619 /* statistics data */
620 struct dtv_fe_stats strength;
621 struct dtv_fe_stats cnr;
622 struct dtv_fe_stats pre_bit_error;
623 struct dtv_fe_stats pre_bit_count;
624 struct dtv_fe_stats post_bit_error;
625 struct dtv_fe_stats post_bit_count;
626 struct dtv_fe_stats block_error;
627 struct dtv_fe_stats block_count;
628};
629
630#define DVB_FE_NO_EXIT 0
631#define DVB_FE_NORMAL_EXIT 1
632#define DVB_FE_DEVICE_REMOVED 2
633#define DVB_FE_DEVICE_RESUME 3
634
635/**
636 * struct dvb_frontend - Frontend structure to be used on drivers.
637 *
638 * @refcount: refcount to keep track of &struct dvb_frontend
639 * references
640 * @ops: embedded &struct dvb_frontend_ops
641 * @dvb: pointer to &struct dvb_adapter
642 * @demodulator_priv: demod private data
643 * @tuner_priv: tuner private data
644 * @frontend_priv: frontend private data
645 * @sec_priv: SEC private data
646 * @analog_demod_priv: Analog demod private data
647 * @dtv_property_cache: embedded &struct dtv_frontend_properties
648 * @callback: callback function used on some drivers to call
649 * either the tuner or the demodulator.
650 * @id: Frontend ID
651 * @exit: Used to inform the DVB core that the frontend
652 * thread should exit (usually, means that the hardware
653 * got disconnected.
654 */
655
656struct dvb_frontend {
657 struct kref refcount;
658 struct dvb_frontend_ops ops;
659 struct dvb_adapter *dvb;
660 void *demodulator_priv;
661 void *tuner_priv;
662 void *frontend_priv;
663 void *sec_priv;
664 void *analog_demod_priv;
665 struct dtv_frontend_properties dtv_property_cache;
666#define DVB_FRONTEND_COMPONENT_TUNER 0
667#define DVB_FRONTEND_COMPONENT_DEMOD 1
668 int (*callback)(void *adapter_priv, int component, int cmd, int arg);
669 int id;
670 unsigned int exit;
671};
672
673/**
674 * dvb_register_frontend() - Registers a DVB frontend at the adapter
675 *
676 * @dvb: pointer to &struct dvb_adapter
677 * @fe: pointer to &struct dvb_frontend
678 *
679 * Allocate and initialize the private data needed by the frontend core to
680 * manage the frontend and calls dvb_register_device() to register a new
681 * frontend. It also cleans the property cache that stores the frontend
682 * parameters and selects the first available delivery system.
683 */
684int dvb_register_frontend(struct dvb_adapter *dvb,
685 struct dvb_frontend *fe);
686
687/**
688 * dvb_unregister_frontend() - Unregisters a DVB frontend
689 *
690 * @fe: pointer to &struct dvb_frontend
691 *
692 * Stops the frontend kthread, calls dvb_unregister_device() and frees the
693 * private frontend data allocated by dvb_register_frontend().
694 *
695 * NOTE: This function doesn't frees the memory allocated by the demod,
696 * by the SEC driver and by the tuner. In order to free it, an explicit call to
697 * dvb_frontend_detach() is needed, after calling this function.
698 */
699int dvb_unregister_frontend(struct dvb_frontend *fe);
700
701/**
702 * dvb_frontend_detach() - Detaches and frees frontend specific data
703 *
704 * @fe: pointer to &struct dvb_frontend
705 *
706 * This function should be called after dvb_unregister_frontend(). It
707 * calls the SEC, tuner and demod release functions:
708 * &dvb_frontend_ops.release_sec, &dvb_frontend_ops.tuner_ops.release,
709 * &dvb_frontend_ops.analog_ops.release and &dvb_frontend_ops.release.
710 *
711 * If the driver is compiled with %CONFIG_MEDIA_ATTACH, it also decreases
712 * the module reference count, needed to allow userspace to remove the
713 * previously used DVB frontend modules.
714 */
715void dvb_frontend_detach(struct dvb_frontend *fe);
716
717/**
718 * dvb_frontend_suspend() - Suspends a Digital TV frontend
719 *
720 * @fe: pointer to &struct dvb_frontend
721 *
722 * This function prepares a Digital TV frontend to suspend.
723 *
724 * In order to prepare the tuner to suspend, if
725 * &dvb_frontend_ops.tuner_ops.suspend\(\) is available, it calls it. Otherwise,
726 * it will call &dvb_frontend_ops.tuner_ops.sleep\(\), if available.
727 *
728 * It will also call &dvb_frontend_ops.sleep\(\) to put the demod to suspend.
729 *
730 * The drivers should also call dvb_frontend_suspend\(\) as part of their
731 * handler for the &device_driver.suspend\(\).
732 */
733int dvb_frontend_suspend(struct dvb_frontend *fe);
734
735/**
736 * dvb_frontend_resume() - Resumes a Digital TV frontend
737 *
738 * @fe: pointer to &struct dvb_frontend
739 *
740 * This function resumes the usual operation of the tuner after resume.
741 *
742 * In order to resume the frontend, it calls the demod &dvb_frontend_ops.init\(\).
743 *
744 * If &dvb_frontend_ops.tuner_ops.resume\(\) is available, It, it calls it.
745 * Otherwise,t will call &dvb_frontend_ops.tuner_ops.init\(\), if available.
746 *
747 * Once tuner and demods are resumed, it will enforce that the SEC voltage and
748 * tone are restored to their previous values and wake up the frontend's
749 * kthread in order to retune the frontend.
750 *
751 * The drivers should also call dvb_frontend_resume() as part of their
752 * handler for the &device_driver.resume\(\).
753 */
754int dvb_frontend_resume(struct dvb_frontend *fe);
755
756/**
757 * dvb_frontend_reinitialise() - forces a reinitialisation at the frontend
758 *
759 * @fe: pointer to &struct dvb_frontend
760 *
761 * Calls &dvb_frontend_ops.init\(\) and &dvb_frontend_ops.tuner_ops.init\(\),
762 * and resets SEC tone and voltage (for Satellite systems).
763 *
764 * NOTE: Currently, this function is used only by one driver (budget-av).
765 * It seems to be due to address some special issue with that specific
766 * frontend.
767 */
768void dvb_frontend_reinitialise(struct dvb_frontend *fe);
769
770/**
771 * dvb_frontend_sleep_until() - Sleep for the amount of time given by
772 * add_usec parameter
773 *
774 * @waketime: pointer to &struct ktime_t
775 * @add_usec: time to sleep, in microseconds
776 *
777 * This function is used to measure the time required for the
778 * FE_DISHNETWORK_SEND_LEGACY_CMD() ioctl to work. It needs to be as precise
779 * as possible, as it affects the detection of the dish tone command at the
780 * satellite subsystem.
781 *
782 * Its used internally by the DVB frontend core, in order to emulate
783 * FE_DISHNETWORK_SEND_LEGACY_CMD() using the &dvb_frontend_ops.set_voltage\(\)
784 * callback.
785 *
786 * NOTE: it should not be used at the drivers, as the emulation for the
787 * legacy callback is provided by the Kernel. The only situation where this
788 * should be at the drivers is when there are some bugs at the hardware that
789 * would prevent the core emulation to work. On such cases, the driver would
790 * be writing a &dvb_frontend_ops.dishnetwork_send_legacy_command\(\) and
791 * calling this function directly.
792 */
793void dvb_frontend_sleep_until(ktime_t *waketime, u32 add_usec);
794
795#endif
diff --git a/include/media/dvb_math.h b/include/media/dvb_math.h
new file mode 100644
index 000000000000..8690ec42954d
--- /dev/null
+++ b/include/media/dvb_math.h
@@ -0,0 +1,66 @@
1/*
2 * dvb-math provides some complex fixed-point math
3 * operations shared between the dvb related stuff
4 *
5 * Copyright (C) 2006 Christoph Pfister (christophpfister@gmail.com)
6 *
7 * This library is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
16 */
17
18#ifndef __DVB_MATH_H
19#define __DVB_MATH_H
20
21#include <linux/types.h>
22
23/**
24 * intlog2 - computes log2 of a value; the result is shifted left by 24 bits
25 *
26 * @value: The value (must be != 0)
27 *
28 * to use rational values you can use the following method:
29 *
30 * intlog2(value) = intlog2(value * 2^x) - x * 2^24
31 *
32 * Some usecase examples:
33 *
34 * intlog2(8) will give 3 << 24 = 3 * 2^24
35 *
36 * intlog2(9) will give 3 << 24 + ... = 3.16... * 2^24
37 *
38 * intlog2(1.5) = intlog2(3) - 2^24 = 0.584... * 2^24
39 *
40 *
41 * return: log2(value) * 2^24
42 */
43extern unsigned int intlog2(u32 value);
44
45/**
46 * intlog10 - computes log10 of a value; the result is shifted left by 24 bits
47 *
48 * @value: The value (must be != 0)
49 *
50 * to use rational values you can use the following method:
51 *
52 * intlog10(value) = intlog10(value * 10^x) - x * 2^24
53 *
54 * An usecase example:
55 *
56 * intlog10(1000) will give 3 << 24 = 3 * 2^24
57 *
58 * due to the implementation intlog10(1000) might be not exactly 3 * 2^24
59 *
60 * look at intlog2 for similar examples
61 *
62 * return: log10(value) * 2^24
63 */
64extern unsigned int intlog10(u32 value);
65
66#endif
diff --git a/include/media/dvb_net.h b/include/media/dvb_net.h
new file mode 100644
index 000000000000..5e31d37f25fa
--- /dev/null
+++ b/include/media/dvb_net.h
@@ -0,0 +1,93 @@
1/*
2 * dvb_net.h
3 *
4 * Copyright (C) 2001 Ralph Metzler for convergence integrated media GmbH
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public License
8 * as published by the Free Software Foundation; either version 2.1
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 */
17
18#ifndef _DVB_NET_H_
19#define _DVB_NET_H_
20
21#include <linux/module.h>
22#include <linux/netdevice.h>
23#include <linux/inetdevice.h>
24#include <linux/etherdevice.h>
25#include <linux/skbuff.h>
26
27#include <media/dvbdev.h>
28
29#define DVB_NET_DEVICES_MAX 10
30
31#ifdef CONFIG_DVB_NET
32
33/**
34 * struct dvb_net - describes a DVB network interface
35 *
36 * @dvbdev: pointer to &struct dvb_device.
37 * @device: array of pointers to &struct net_device.
38 * @state: array of integers to each net device. A value
39 * different than zero means that the interface is
40 * in usage.
41 * @exit: flag to indicate when the device is being removed.
42 * @demux: pointer to &struct dmx_demux.
43 * @ioctl_mutex: protect access to this struct.
44 *
45 * Currently, the core supports up to %DVB_NET_DEVICES_MAX (10) network
46 * devices.
47 */
48
49struct dvb_net {
50 struct dvb_device *dvbdev;
51 struct net_device *device[DVB_NET_DEVICES_MAX];
52 int state[DVB_NET_DEVICES_MAX];
53 unsigned int exit:1;
54 struct dmx_demux *demux;
55 struct mutex ioctl_mutex;
56};
57
58/**
59 * dvb_net_init - nitializes a digital TV network device and registers it.
60 *
61 * @adap: pointer to &struct dvb_adapter.
62 * @dvbnet: pointer to &struct dvb_net.
63 * @dmxdemux: pointer to &struct dmx_demux.
64 */
65int dvb_net_init(struct dvb_adapter *adap, struct dvb_net *dvbnet,
66 struct dmx_demux *dmxdemux);
67
68/**
69 * dvb_net_release - releases a digital TV network device and unregisters it.
70 *
71 * @dvbnet: pointer to &struct dvb_net.
72 */
73void dvb_net_release(struct dvb_net *dvbnet);
74
75#else
76
77struct dvb_net {
78 struct dvb_device *dvbdev;
79};
80
81static inline void dvb_net_release(struct dvb_net *dvbnet)
82{
83}
84
85static inline int dvb_net_init(struct dvb_adapter *adap,
86 struct dvb_net *dvbnet, struct dmx_demux *dmx)
87{
88 return 0;
89}
90
91#endif /* ifdef CONFIG_DVB_NET */
92
93#endif
diff --git a/include/media/dvb_ringbuffer.h b/include/media/dvb_ringbuffer.h
new file mode 100644
index 000000000000..8ed6bcc3a56e
--- /dev/null
+++ b/include/media/dvb_ringbuffer.h
@@ -0,0 +1,280 @@
1/*
2 *
3 * dvb_ringbuffer.h: ring buffer implementation for the dvb driver
4 *
5 * Copyright (C) 2003 Oliver Endriss
6 * Copyright (C) 2004 Andrew de Quincey
7 *
8 * based on code originally found in av7110.c & dvb_ci.c:
9 * Copyright (C) 1999-2003 Ralph Metzler & Marcus Metzler
10 * for convergence integrated media GmbH
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public License
14 * as published by the Free Software Foundation; either version 2.1
15 * of the License, or (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Lesser General Public License for more details.
21 */
22
23#ifndef _DVB_RINGBUFFER_H_
24#define _DVB_RINGBUFFER_H_
25
26#include <linux/spinlock.h>
27#include <linux/wait.h>
28
29/**
30 * struct dvb_ringbuffer - Describes a ring buffer used at DVB framework
31 *
32 * @data: Area were the ringbuffer data is written
33 * @size: size of the ringbuffer
34 * @pread: next position to read
35 * @pwrite: next position to write
36 * @error: used by ringbuffer clients to indicate that an error happened.
37 * @queue: Wait queue used by ringbuffer clients to indicate when buffer
38 * was filled
39 * @lock: Spinlock used to protect the ringbuffer
40 */
41struct dvb_ringbuffer {
42 u8 *data;
43 ssize_t size;
44 ssize_t pread;
45 ssize_t pwrite;
46 int error;
47
48 wait_queue_head_t queue;
49 spinlock_t lock;
50};
51
52#define DVB_RINGBUFFER_PKTHDRSIZE 3
53
54/**
55 * dvb_ringbuffer_init - initialize ring buffer, lock and queue
56 *
57 * @rbuf: pointer to struct dvb_ringbuffer
58 * @data: pointer to the buffer where the data will be stored
59 * @len: bytes from ring buffer into @buf
60 */
61extern void dvb_ringbuffer_init(struct dvb_ringbuffer *rbuf, void *data,
62 size_t len);
63
64/**
65 * dvb_ringbuffer_empty - test whether buffer is empty
66 *
67 * @rbuf: pointer to struct dvb_ringbuffer
68 */
69extern int dvb_ringbuffer_empty(struct dvb_ringbuffer *rbuf);
70
71/**
72 * dvb_ringbuffer_free - returns the number of free bytes in the buffer
73 *
74 * @rbuf: pointer to struct dvb_ringbuffer
75 *
76 * Return: number of free bytes in the buffer
77 */
78extern ssize_t dvb_ringbuffer_free(struct dvb_ringbuffer *rbuf);
79
80/**
81 * dvb_ringbuffer_avail - returns the number of bytes waiting in the buffer
82 *
83 * @rbuf: pointer to struct dvb_ringbuffer
84 *
85 * Return: number of bytes waiting in the buffer
86 */
87extern ssize_t dvb_ringbuffer_avail(struct dvb_ringbuffer *rbuf);
88
89/**
90 * dvb_ringbuffer_reset - resets the ringbuffer to initial state
91 *
92 * @rbuf: pointer to struct dvb_ringbuffer
93 *
94 * Resets the read and write pointers to zero and flush the buffer.
95 *
96 * This counts as a read and write operation
97 */
98extern void dvb_ringbuffer_reset(struct dvb_ringbuffer *rbuf);
99
100/*
101 * read routines & macros
102 */
103
104/**
105 * dvb_ringbuffer_flush - flush buffer
106 *
107 * @rbuf: pointer to struct dvb_ringbuffer
108 */
109extern void dvb_ringbuffer_flush(struct dvb_ringbuffer *rbuf);
110
111/**
112 * dvb_ringbuffer_flush_spinlock_wakeup- flush buffer protected by spinlock
113 * and wake-up waiting task(s)
114 *
115 * @rbuf: pointer to struct dvb_ringbuffer
116 */
117extern void dvb_ringbuffer_flush_spinlock_wakeup(struct dvb_ringbuffer *rbuf);
118
119/**
120 * DVB_RINGBUFFER_PEEK - peek at byte @offs in the buffer
121 *
122 * @rbuf: pointer to struct dvb_ringbuffer
123 * @offs: offset inside the ringbuffer
124 */
125#define DVB_RINGBUFFER_PEEK(rbuf, offs) \
126 ((rbuf)->data[((rbuf)->pread + (offs)) % (rbuf)->size])
127
128/**
129 * DVB_RINGBUFFER_SKIP - advance read ptr by @num bytes
130 *
131 * @rbuf: pointer to struct dvb_ringbuffer
132 * @num: number of bytes to advance
133 */
134#define DVB_RINGBUFFER_SKIP(rbuf, num) {\
135 (rbuf)->pread = ((rbuf)->pread + (num)) % (rbuf)->size;\
136}
137
138/**
139 * dvb_ringbuffer_read_user - Reads a buffer into a user pointer
140 *
141 * @rbuf: pointer to struct dvb_ringbuffer
142 * @buf: pointer to the buffer where the data will be stored
143 * @len: bytes from ring buffer into @buf
144 *
145 * This variant assumes that the buffer is a memory at the userspace. So,
146 * it will internally call copy_to_user().
147 *
148 * Return: number of bytes transferred or -EFAULT
149 */
150extern ssize_t dvb_ringbuffer_read_user(struct dvb_ringbuffer *rbuf,
151 u8 __user *buf, size_t len);
152
153/**
154 * dvb_ringbuffer_read - Reads a buffer into a pointer
155 *
156 * @rbuf: pointer to struct dvb_ringbuffer
157 * @buf: pointer to the buffer where the data will be stored
158 * @len: bytes from ring buffer into @buf
159 *
160 * This variant assumes that the buffer is a memory at the Kernel space
161 *
162 * Return: number of bytes transferred or -EFAULT
163 */
164extern void dvb_ringbuffer_read(struct dvb_ringbuffer *rbuf,
165 u8 *buf, size_t len);
166
167/*
168 * write routines & macros
169 */
170
171/**
172 * DVB_RINGBUFFER_WRITE_BYTE - write single byte to ring buffer
173 *
174 * @rbuf: pointer to struct dvb_ringbuffer
175 * @byte: byte to write
176 */
177#define DVB_RINGBUFFER_WRITE_BYTE(rbuf, byte) \
178 { (rbuf)->data[(rbuf)->pwrite] = (byte); \
179 (rbuf)->pwrite = ((rbuf)->pwrite + 1) % (rbuf)->size; }
180
181/**
182 * dvb_ringbuffer_write - Writes a buffer into the ringbuffer
183 *
184 * @rbuf: pointer to struct dvb_ringbuffer
185 * @buf: pointer to the buffer where the data will be read
186 * @len: bytes from ring buffer into @buf
187 *
188 * This variant assumes that the buffer is a memory at the Kernel space
189 *
190 * return: number of bytes transferred or -EFAULT
191 */
192extern ssize_t dvb_ringbuffer_write(struct dvb_ringbuffer *rbuf, const u8 *buf,
193 size_t len);
194
195/**
196 * dvb_ringbuffer_write_user - Writes a buffer received via a user pointer
197 *
198 * @rbuf: pointer to struct dvb_ringbuffer
199 * @buf: pointer to the buffer where the data will be read
200 * @len: bytes from ring buffer into @buf
201 *
202 * This variant assumes that the buffer is a memory at the userspace. So,
203 * it will internally call copy_from_user().
204 *
205 * Return: number of bytes transferred or -EFAULT
206 */
207extern ssize_t dvb_ringbuffer_write_user(struct dvb_ringbuffer *rbuf,
208 const u8 __user *buf, size_t len);
209
210/**
211 * dvb_ringbuffer_pkt_write - Write a packet into the ringbuffer.
212 *
213 * @rbuf: Ringbuffer to write to.
214 * @buf: Buffer to write.
215 * @len: Length of buffer (currently limited to 65535 bytes max).
216 *
217 * Return: Number of bytes written, or -EFAULT, -ENOMEM, -EVINAL.
218 */
219extern ssize_t dvb_ringbuffer_pkt_write(struct dvb_ringbuffer *rbuf, u8 *buf,
220 size_t len);
221
222/**
223 * dvb_ringbuffer_pkt_read_user - Read from a packet in the ringbuffer.
224 *
225 * @rbuf: Ringbuffer concerned.
226 * @idx: Packet index as returned by dvb_ringbuffer_pkt_next().
227 * @offset: Offset into packet to read from.
228 * @buf: Destination buffer for data.
229 * @len: Size of destination buffer.
230 *
231 * Return: Number of bytes read, or -EFAULT.
232 *
233 * .. note::
234 *
235 * unlike dvb_ringbuffer_read(), this does **NOT** update the read pointer
236 * in the ringbuffer. You must use dvb_ringbuffer_pkt_dispose() to mark a
237 * packet as no longer required.
238 */
239extern ssize_t dvb_ringbuffer_pkt_read_user(struct dvb_ringbuffer *rbuf,
240 size_t idx,
241 int offset, u8 __user *buf,
242 size_t len);
243
244/**
245 * dvb_ringbuffer_pkt_read - Read from a packet in the ringbuffer.
246 * Note: unlike dvb_ringbuffer_read_user(), this DOES update the read pointer
247 * in the ringbuffer.
248 *
249 * @rbuf: Ringbuffer concerned.
250 * @idx: Packet index as returned by dvb_ringbuffer_pkt_next().
251 * @offset: Offset into packet to read from.
252 * @buf: Destination buffer for data.
253 * @len: Size of destination buffer.
254 *
255 * Return: Number of bytes read, or -EFAULT.
256 */
257extern ssize_t dvb_ringbuffer_pkt_read(struct dvb_ringbuffer *rbuf, size_t idx,
258 int offset, u8 *buf, size_t len);
259
260/**
261 * dvb_ringbuffer_pkt_dispose - Dispose of a packet in the ring buffer.
262 *
263 * @rbuf: Ring buffer concerned.
264 * @idx: Packet index as returned by dvb_ringbuffer_pkt_next().
265 */
266extern void dvb_ringbuffer_pkt_dispose(struct dvb_ringbuffer *rbuf, size_t idx);
267
268/**
269 * dvb_ringbuffer_pkt_next - Get the index of the next packet in a ringbuffer.
270 *
271 * @rbuf: Ringbuffer concerned.
272 * @idx: Previous packet index, or -1 to return the first packet index.
273 * @pktlen: On success, will be updated to contain the length of the packet
274 * in bytes.
275 * returns Packet index (if >=0), or -1 if no packets available.
276 */
277extern ssize_t dvb_ringbuffer_pkt_next(struct dvb_ringbuffer *rbuf,
278 size_t idx, size_t *pktlen);
279
280#endif /* _DVB_RINGBUFFER_H_ */
diff --git a/include/media/dvb_vb2.h b/include/media/dvb_vb2.h
new file mode 100644
index 000000000000..01d1202d1a55
--- /dev/null
+++ b/include/media/dvb_vb2.h
@@ -0,0 +1,266 @@
1/*
2 * SPDX-License-Identifier: GPL-2.0
3 *
4 * dvb-vb2.h - DVB driver helper framework for streaming I/O
5 *
6 * Copyright (C) 2015 Samsung Electronics
7 *
8 * Author: jh1009.sung@samsung.com
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation.
13 */
14
15#ifndef _DVB_VB2_H
16#define _DVB_VB2_H
17
18#include <linux/mutex.h>
19#include <linux/poll.h>
20#include <linux/dvb/dmx.h>
21#include <media/videobuf2-core.h>
22#include <media/videobuf2-dma-contig.h>
23#include <media/videobuf2-vmalloc.h>
24
25/**
26 * enum dvb_buf_type - types of Digital TV memory-mapped buffers
27 *
28 * @DVB_BUF_TYPE_CAPTURE: buffer is filled by the Kernel,
29 * with a received Digital TV stream
30 */
31enum dvb_buf_type {
32 DVB_BUF_TYPE_CAPTURE = 1,
33};
34
35/**
36 * enum dvb_vb2_states - states to control VB2 state machine
37 * @DVB_VB2_STATE_NONE:
38 * VB2 engine not initialized yet, init failed or VB2 was released.
39 * @DVB_VB2_STATE_INIT:
40 * VB2 engine initialized.
41 * @DVB_VB2_STATE_REQBUFS:
42 * Buffers were requested
43 * @DVB_VB2_STATE_STREAMON:
44 * VB2 is streaming. Callers should not check it directly. Instead,
45 * they should use dvb_vb2_is_streaming().
46 *
47 * Note:
48 *
49 * Callers should not touch at the state machine directly. This
50 * is handled inside dvb_vb2.c.
51 */
52enum dvb_vb2_states {
53 DVB_VB2_STATE_NONE = 0x0,
54 DVB_VB2_STATE_INIT = 0x1,
55 DVB_VB2_STATE_REQBUFS = 0x2,
56 DVB_VB2_STATE_STREAMON = 0x4,
57};
58
59#define DVB_VB2_NAME_MAX (20)
60
61/**
62 * struct dvb_buffer - video buffer information for v4l2.
63 *
64 * @vb: embedded struct &vb2_buffer.
65 * @list: list of &struct dvb_buffer.
66 */
67struct dvb_buffer {
68 struct vb2_buffer vb;
69 struct list_head list;
70};
71
72/**
73 * struct dvb_vb2_ctx - control struct for VB2 handler
74 * @vb_q: pointer to &struct vb2_queue with videobuf2 queue.
75 * @mutex: mutex to serialize vb2 operations. Used by
76 * vb2 core %wait_prepare and %wait_finish operations.
77 * @slock: spin lock used to protect buffer filling at dvb_vb2.c.
78 * @dvb_q: List of buffers that are not filled yet.
79 * @buf: Pointer to the buffer that are currently being filled.
80 * @offset: index to the next position at the @buf to be filled.
81 * @remain: How many bytes are left to be filled at @buf.
82 * @state: bitmask of buffer states as defined by &enum dvb_vb2_states.
83 * @buf_siz: size of each VB2 buffer.
84 * @buf_cnt: number of VB2 buffers.
85 * @nonblocking:
86 * If different than zero, device is operating on non-blocking
87 * mode.
88 * @name: name of the device type. Currently, it can either be
89 * "dvr" or "demux_filter".
90 */
91struct dvb_vb2_ctx {
92 struct vb2_queue vb_q;
93 struct mutex mutex;
94 spinlock_t slock;
95 struct list_head dvb_q;
96 struct dvb_buffer *buf;
97 int offset;
98 int remain;
99 int state;
100 int buf_siz;
101 int buf_cnt;
102 int nonblocking;
103 char name[DVB_VB2_NAME_MAX + 1];
104};
105
106#ifndef DVB_MMAP
107static inline int dvb_vb2_init(struct dvb_vb2_ctx *ctx,
108 const char *name, int non_blocking)
109{
110 return 0;
111};
112static inline int dvb_vb2_release(struct dvb_vb2_ctx *ctx)
113{
114 return 0;
115};
116#define dvb_vb2_is_streaming(ctx) (0)
117#define dvb_vb2_fill_buffer(ctx, file, wait) (0)
118
119static inline __poll_t dvb_vb2_poll(struct dvb_vb2_ctx *ctx,
120 struct file *file,
121 poll_table *wait)
122{
123 return 0;
124}
125#else
126/**
127 * dvb_vb2_init - initializes VB2 handler
128 *
129 * @ctx: control struct for VB2 handler
130 * @name: name for the VB2 handler
131 * @non_blocking:
132 * if not zero, it means that the device is at non-blocking mode
133 */
134int dvb_vb2_init(struct dvb_vb2_ctx *ctx, const char *name, int non_blocking);
135
136/**
137 * dvb_vb2_release - Releases the VB2 handler allocated resources and
138 * put @ctx at DVB_VB2_STATE_NONE state.
139 * @ctx: control struct for VB2 handler
140 */
141int dvb_vb2_release(struct dvb_vb2_ctx *ctx);
142
143/**
144 * dvb_vb2_is_streaming - checks if the VB2 handler is streaming
145 * @ctx: control struct for VB2 handler
146 *
147 * Return: 0 if not streaming, 1 otherwise.
148 */
149int dvb_vb2_is_streaming(struct dvb_vb2_ctx *ctx);
150
151/**
152 * dvb_vb2_fill_buffer - fills a VB2 buffer
153 * @ctx: control struct for VB2 handler
154 * @src: place where the data is stored
155 * @len: number of bytes to be copied from @src
156 */
157int dvb_vb2_fill_buffer(struct dvb_vb2_ctx *ctx,
158 const unsigned char *src, int len);
159
160/**
161 * dvb_vb2_poll - Wrapper to vb2_core_streamon() for Digital TV
162 * buffer handling.
163 *
164 * @ctx: control struct for VB2 handler
165 * @file: &struct file argument passed to the poll
166 * file operation handler.
167 * @wait: &poll_table wait argument passed to the poll
168 * file operation handler.
169 *
170 * Implements poll syscall() logic.
171 */
172__poll_t dvb_vb2_poll(struct dvb_vb2_ctx *ctx, struct file *file,
173 poll_table *wait);
174#endif
175
176/**
177 * dvb_vb2_stream_on() - Wrapper to vb2_core_streamon() for Digital TV
178 * buffer handling.
179 *
180 * @ctx: control struct for VB2 handler
181 *
182 * Starts dvb streaming
183 */
184int dvb_vb2_stream_on(struct dvb_vb2_ctx *ctx);
185/**
186 * dvb_vb2_stream_off() - Wrapper to vb2_core_streamoff() for Digital TV
187 * buffer handling.
188 *
189 * @ctx: control struct for VB2 handler
190 *
191 * Stops dvb streaming
192 */
193int dvb_vb2_stream_off(struct dvb_vb2_ctx *ctx);
194
195/**
196 * dvb_vb2_reqbufs() - Wrapper to vb2_core_reqbufs() for Digital TV
197 * buffer handling.
198 *
199 * @ctx: control struct for VB2 handler
200 * @req: &struct dmx_requestbuffers passed from userspace in
201 * order to handle &DMX_REQBUFS.
202 *
203 * Initiate streaming by requesting a number of buffers. Also used to
204 * free previously requested buffers, is ``req->count`` is zero.
205 */
206int dvb_vb2_reqbufs(struct dvb_vb2_ctx *ctx, struct dmx_requestbuffers *req);
207
208/**
209 * dvb_vb2_querybuf() - Wrapper to vb2_core_querybuf() for Digital TV
210 * buffer handling.
211 *
212 * @ctx: control struct for VB2 handler
213 * @b: &struct dmx_buffer passed from userspace in
214 * order to handle &DMX_QUERYBUF.
215 *
216 *
217 */
218int dvb_vb2_querybuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b);
219
220/**
221 * dvb_vb2_expbuf() - Wrapper to vb2_core_expbuf() for Digital TV
222 * buffer handling.
223 *
224 * @ctx: control struct for VB2 handler
225 * @exp: &struct dmx_exportbuffer passed from userspace in
226 * order to handle &DMX_EXPBUF.
227 *
228 * Export a buffer as a file descriptor.
229 */
230int dvb_vb2_expbuf(struct dvb_vb2_ctx *ctx, struct dmx_exportbuffer *exp);
231
232/**
233 * dvb_vb2_qbuf() - Wrapper to vb2_core_qbuf() for Digital TV buffer handling.
234 *
235 * @ctx: control struct for VB2 handler
236 * @b: &struct dmx_buffer passed from userspace in
237 * order to handle &DMX_QBUF.
238 *
239 * Queue a Digital TV buffer as requested by userspace
240 */
241int dvb_vb2_qbuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b);
242
243/**
244 * dvb_vb2_dqbuf() - Wrapper to vb2_core_dqbuf() for Digital TV
245 * buffer handling.
246 *
247 * @ctx: control struct for VB2 handler
248 * @b: &struct dmx_buffer passed from userspace in
249 * order to handle &DMX_DQBUF.
250 *
251 * Dequeue a Digital TV buffer to the userspace
252 */
253int dvb_vb2_dqbuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b);
254
255/**
256 * dvb_vb2_mmap() - Wrapper to vb2_mmap() for Digital TV buffer handling.
257 *
258 * @ctx: control struct for VB2 handler
259 * @vma: pointer to &struct vm_area_struct with the vma passed
260 * to the mmap file operation handler in the driver.
261 *
262 * map Digital TV video buffers into application address space.
263 */
264int dvb_vb2_mmap(struct dvb_vb2_ctx *ctx, struct vm_area_struct *vma);
265
266#endif /* _DVB_VB2_H */
diff --git a/include/media/dvbdev.h b/include/media/dvbdev.h
new file mode 100644
index 000000000000..554db879527f
--- /dev/null
+++ b/include/media/dvbdev.h
@@ -0,0 +1,407 @@
1/*
2 * dvbdev.h
3 *
4 * Copyright (C) 2000 Ralph Metzler & Marcus Metzler
5 * for convergence integrated media GmbH
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Lesser Public License
9 * as published by the Free Software Foundation; either version 2.1
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 */
18
19#ifndef _DVBDEV_H_
20#define _DVBDEV_H_
21
22#include <linux/types.h>
23#include <linux/poll.h>
24#include <linux/fs.h>
25#include <linux/list.h>
26#include <media/media-device.h>
27
28#define DVB_MAJOR 212
29
30#if defined(CONFIG_DVB_MAX_ADAPTERS) && CONFIG_DVB_MAX_ADAPTERS > 0
31 #define DVB_MAX_ADAPTERS CONFIG_DVB_MAX_ADAPTERS
32#else
33 #define DVB_MAX_ADAPTERS 16
34#endif
35
36#define DVB_UNSET (-1)
37
38/* List of DVB device types */
39
40/**
41 * enum dvb_device_type - type of the Digital TV device
42 *
43 * @DVB_DEVICE_SEC: Digital TV standalone Common Interface (CI)
44 * @DVB_DEVICE_FRONTEND: Digital TV frontend.
45 * @DVB_DEVICE_DEMUX: Digital TV demux.
46 * @DVB_DEVICE_DVR: Digital TV digital video record (DVR).
47 * @DVB_DEVICE_CA: Digital TV Conditional Access (CA).
48 * @DVB_DEVICE_NET: Digital TV network.
49 *
50 * @DVB_DEVICE_VIDEO: Digital TV video decoder.
51 * Deprecated. Used only on av7110-av.
52 * @DVB_DEVICE_AUDIO: Digital TV audio decoder.
53 * Deprecated. Used only on av7110-av.
54 * @DVB_DEVICE_OSD: Digital TV On Screen Display (OSD).
55 * Deprecated. Used only on av7110.
56 */
57enum dvb_device_type {
58 DVB_DEVICE_SEC,
59 DVB_DEVICE_FRONTEND,
60 DVB_DEVICE_DEMUX,
61 DVB_DEVICE_DVR,
62 DVB_DEVICE_CA,
63 DVB_DEVICE_NET,
64
65 DVB_DEVICE_VIDEO,
66 DVB_DEVICE_AUDIO,
67 DVB_DEVICE_OSD,
68};
69
70#define DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr) \
71 static short adapter_nr[] = \
72 {[0 ... (DVB_MAX_ADAPTERS - 1)] = DVB_UNSET }; \
73 module_param_array(adapter_nr, short, NULL, 0444); \
74 MODULE_PARM_DESC(adapter_nr, "DVB adapter numbers")
75
76struct dvb_frontend;
77
78/**
79 * struct dvb_adapter - represents a Digital TV adapter using Linux DVB API
80 *
81 * @num: Number of the adapter
82 * @list_head: List with the DVB adapters
83 * @device_list: List with the DVB devices
84 * @name: Name of the adapter
85 * @proposed_mac: proposed MAC address for the adapter
86 * @priv: private data
87 * @device: pointer to struct device
88 * @module: pointer to struct module
89 * @mfe_shared: mfe shared: indicates mutually exclusive frontends
90 * Thie usage of this flag is currently deprecated
91 * @mfe_dvbdev: Frontend device in use, in the case of MFE
92 * @mfe_lock: Lock to prevent using the other frontends when MFE is
93 * used.
94 * @mdev: pointer to struct media_device, used when the media
95 * controller is used.
96 * @conn: RF connector. Used only if the device has no separate
97 * tuner.
98 * @conn_pads: pointer to struct media_pad associated with @conn;
99 */
100struct dvb_adapter {
101 int num;
102 struct list_head list_head;
103 struct list_head device_list;
104 const char *name;
105 u8 proposed_mac [6];
106 void* priv;
107
108 struct device *device;
109
110 struct module *module;
111
112 int mfe_shared; /* indicates mutually exclusive frontends */
113 struct dvb_device *mfe_dvbdev; /* frontend device in use */
114 struct mutex mfe_lock; /* access lock for thread creation */
115
116#if defined(CONFIG_MEDIA_CONTROLLER_DVB)
117 struct media_device *mdev;
118 struct media_entity *conn;
119 struct media_pad *conn_pads;
120#endif
121};
122
123/**
124 * struct dvb_device - represents a DVB device node
125 *
126 * @list_head: List head with all DVB devices
127 * @fops: pointer to struct file_operations
128 * @adapter: pointer to the adapter that holds this device node
129 * @type: type of the device, as defined by &enum dvb_device_type.
130 * @minor: devnode minor number. Major number is always DVB_MAJOR.
131 * @id: device ID number, inside the adapter
132 * @readers: Initialized by the caller. Each call to open() in Read Only mode
133 * decreases this counter by one.
134 * @writers: Initialized by the caller. Each call to open() in Read/Write
135 * mode decreases this counter by one.
136 * @users: Initialized by the caller. Each call to open() in any mode
137 * decreases this counter by one.
138 * @wait_queue: wait queue, used to wait for certain events inside one of
139 * the DVB API callers
140 * @kernel_ioctl: callback function used to handle ioctl calls from userspace.
141 * @name: Name to be used for the device at the Media Controller
142 * @entity: pointer to struct media_entity associated with the device node
143 * @pads: pointer to struct media_pad associated with @entity;
144 * @priv: private data
145 * @intf_devnode: Pointer to media_intf_devnode. Used by the dvbdev core to
146 * store the MC device node interface
147 * @tsout_num_entities: Number of Transport Stream output entities
148 * @tsout_entity: array with MC entities associated to each TS output node
149 * @tsout_pads: array with the source pads for each @tsout_entity
150 *
151 * This structure is used by the DVB core (frontend, CA, net, demux) in
152 * order to create the device nodes. Usually, driver should not initialize
153 * this struct diretly.
154 */
155struct dvb_device {
156 struct list_head list_head;
157 const struct file_operations *fops;
158 struct dvb_adapter *adapter;
159 enum dvb_device_type type;
160 int minor;
161 u32 id;
162
163 /* in theory, 'users' can vanish now,
164 but I don't want to change too much now... */
165 int readers;
166 int writers;
167 int users;
168
169 wait_queue_head_t wait_queue;
170 /* don't really need those !? -- FIXME: use video_usercopy */
171 int (*kernel_ioctl)(struct file *file, unsigned int cmd, void *arg);
172
173 /* Needed for media controller register/unregister */
174#if defined(CONFIG_MEDIA_CONTROLLER_DVB)
175 const char *name;
176
177 /* Allocated and filled inside dvbdev.c */
178 struct media_intf_devnode *intf_devnode;
179
180 unsigned tsout_num_entities;
181 struct media_entity *entity, *tsout_entity;
182 struct media_pad *pads, *tsout_pads;
183#endif
184
185 void *priv;
186};
187
188/**
189 * dvb_register_adapter - Registers a new DVB adapter
190 *
191 * @adap: pointer to struct dvb_adapter
192 * @name: Adapter's name
193 * @module: initialized with THIS_MODULE at the caller
194 * @device: pointer to struct device that corresponds to the device driver
195 * @adapter_nums: Array with a list of the numbers for @dvb_register_adapter;
196 * to select among them. Typically, initialized with:
197 * DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nums)
198 */
199int dvb_register_adapter(struct dvb_adapter *adap, const char *name,
200 struct module *module, struct device *device,
201 short *adapter_nums);
202
203/**
204 * dvb_unregister_adapter - Unregisters a DVB adapter
205 *
206 * @adap: pointer to struct dvb_adapter
207 */
208int dvb_unregister_adapter(struct dvb_adapter *adap);
209
210/**
211 * dvb_register_device - Registers a new DVB device
212 *
213 * @adap: pointer to struct dvb_adapter
214 * @pdvbdev: pointer to the place where the new struct dvb_device will be
215 * stored
216 * @template: Template used to create &pdvbdev;
217 * @priv: private data
218 * @type: type of the device, as defined by &enum dvb_device_type.
219 * @demux_sink_pads: Number of demux outputs, to be used to create the TS
220 * outputs via the Media Controller.
221 */
222int dvb_register_device(struct dvb_adapter *adap,
223 struct dvb_device **pdvbdev,
224 const struct dvb_device *template,
225 void *priv,
226 enum dvb_device_type type,
227 int demux_sink_pads);
228
229/**
230 * dvb_remove_device - Remove a registered DVB device
231 *
232 * This does not free memory. To do that, call dvb_free_device().
233 *
234 * @dvbdev: pointer to struct dvb_device
235 */
236void dvb_remove_device(struct dvb_device *dvbdev);
237
238/**
239 * dvb_free_device - Free memory occupied by a DVB device.
240 *
241 * Call dvb_unregister_device() before calling this function.
242 *
243 * @dvbdev: pointer to struct dvb_device
244 */
245void dvb_free_device(struct dvb_device *dvbdev);
246
247/**
248 * dvb_unregister_device - Unregisters a DVB device
249 *
250 * This is a combination of dvb_remove_device() and dvb_free_device().
251 * Using this function is usually a mistake, and is often an indicator
252 * for a use-after-free bug (when a userspace process keeps a file
253 * handle to a detached device).
254 *
255 * @dvbdev: pointer to struct dvb_device
256 */
257void dvb_unregister_device(struct dvb_device *dvbdev);
258
259#ifdef CONFIG_MEDIA_CONTROLLER_DVB
260/**
261 * dvb_create_media_graph - Creates media graph for the Digital TV part of the
262 * device.
263 *
264 * @adap: pointer to &struct dvb_adapter
265 * @create_rf_connector: if true, it creates the RF connector too
266 *
267 * This function checks all DVB-related functions at the media controller
268 * entities and creates the needed links for the media graph. It is
269 * capable of working with multiple tuners or multiple frontends, but it
270 * won't create links if the device has multiple tuners and multiple frontends
271 * or if the device has multiple muxes. In such case, the caller driver should
272 * manually create the remaining links.
273 */
274__must_check int dvb_create_media_graph(struct dvb_adapter *adap,
275 bool create_rf_connector);
276
277/**
278 * dvb_register_media_controller - registers a media controller at DVB adapter
279 *
280 * @adap: pointer to &struct dvb_adapter
281 * @mdev: pointer to &struct media_device
282 */
283static inline void dvb_register_media_controller(struct dvb_adapter *adap,
284 struct media_device *mdev)
285{
286 adap->mdev = mdev;
287}
288
289/**
290 * dvb_get_media_controller - gets the associated media controller
291 *
292 * @adap: pointer to &struct dvb_adapter
293 */
294static inline struct media_device
295*dvb_get_media_controller(struct dvb_adapter *adap)
296{
297 return adap->mdev;
298}
299#else
300static inline
301int dvb_create_media_graph(struct dvb_adapter *adap,
302 bool create_rf_connector)
303{
304 return 0;
305};
306#define dvb_register_media_controller(a, b) {}
307#define dvb_get_media_controller(a) NULL
308#endif
309
310/**
311 * dvb_generic_open - Digital TV open function, used by DVB devices
312 *
313 * @inode: pointer to &struct inode.
314 * @file: pointer to &struct file.
315 *
316 * Checks if a DVB devnode is still valid, and if the permissions are
317 * OK and increment negative use count.
318 */
319int dvb_generic_open(struct inode *inode, struct file *file);
320
321/**
322 * dvb_generic_close - Digital TV close function, used by DVB devices
323 *
324 * @inode: pointer to &struct inode.
325 * @file: pointer to &struct file.
326 *
327 * Checks if a DVB devnode is still valid, and if the permissions are
328 * OK and decrement negative use count.
329 */
330int dvb_generic_release(struct inode *inode, struct file *file);
331
332/**
333 * dvb_generic_ioctl - Digital TV close function, used by DVB devices
334 *
335 * @file: pointer to &struct file.
336 * @cmd: Ioctl name.
337 * @arg: Ioctl argument.
338 *
339 * Checks if a DVB devnode and struct dvbdev.kernel_ioctl is still valid.
340 * If so, calls dvb_usercopy().
341 */
342long dvb_generic_ioctl(struct file *file,
343 unsigned int cmd, unsigned long arg);
344
345/**
346 * dvb_usercopy - copies data from/to userspace memory when an ioctl is
347 * issued.
348 *
349 * @file: Pointer to struct &file.
350 * @cmd: Ioctl name.
351 * @arg: Ioctl argument.
352 * @func: function that will actually handle the ioctl
353 *
354 * Ancillary function that uses ioctl direction and size to copy from
355 * userspace. Then, it calls @func, and, if needed, data is copied back
356 * to userspace.
357 */
358int dvb_usercopy(struct file *file, unsigned int cmd, unsigned long arg,
359 int (*func)(struct file *file, unsigned int cmd, void *arg));
360
361/** generic DVB attach function. */
362#ifdef CONFIG_MEDIA_ATTACH
363
364/**
365 * dvb_attach - attaches a DVB frontend into the DVB core.
366 *
367 * @FUNCTION: function on a frontend module to be called.
368 * @ARGS...: @FUNCTION arguments.
369 *
370 * This ancillary function loads a frontend module in runtime and runs
371 * the @FUNCTION function there, with @ARGS.
372 * As it increments symbol usage cont, at unregister, dvb_detach()
373 * should be called.
374 */
375#define dvb_attach(FUNCTION, ARGS...) ({ \
376 void *__r = NULL; \
377 typeof(&FUNCTION) __a = symbol_request(FUNCTION); \
378 if (__a) { \
379 __r = (void *) __a(ARGS); \
380 if (__r == NULL) \
381 symbol_put(FUNCTION); \
382 } else { \
383 printk(KERN_ERR "DVB: Unable to find symbol "#FUNCTION"()\n"); \
384 } \
385 __r; \
386})
387
388/**
389 * dvb_detach - detaches a DVB frontend loaded via dvb_attach()
390 *
391 * @FUNC: attach function
392 *
393 * Decrements usage count for a function previously called via dvb_attach().
394 */
395
396#define dvb_detach(FUNC) symbol_put_addr(FUNC)
397
398#else
399#define dvb_attach(FUNCTION, ARGS...) ({ \
400 FUNCTION(ARGS); \
401})
402
403#define dvb_detach(FUNC) {}
404
405#endif
406
407#endif /* #ifndef _DVBDEV_H_ */
diff --git a/include/media/i2c-addr.h b/include/media/i2c-addr.h
deleted file mode 100644
index 1b6872f5e970..000000000000
--- a/include/media/i2c-addr.h
+++ /dev/null
@@ -1,43 +0,0 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * V4L I2C address list
4 *
5 *
6 * Copyright (C) 2006 Mauro Carvalho Chehab <mchehab@infradead.org>
7 * Based on a previous mapping by
8 * Ralph Metzler (rjkm@thp.uni-koeln.de)
9 * Gerd Knorr <kraxel@goldbach.in-berlin.de>
10 *
11 */
12
13/* bttv address list */
14#define I2C_ADDR_TSA5522 0xc2
15#define I2C_ADDR_TDA7432 0x8a
16#define I2C_ADDR_TDA8425 0x82
17#define I2C_ADDR_TDA9840 0x84
18#define I2C_ADDR_TDA9850 0xb6 /* also used by 9855,9873 */
19#define I2C_ADDR_TDA9874 0xb0 /* also used by 9875 */
20#define I2C_ADDR_TDA9875 0xb0
21#define I2C_ADDR_HAUPEE 0xa0
22#define I2C_ADDR_STBEE 0xae
23#define I2C_ADDR_VHX 0xc0
24#define I2C_ADDR_MSP3400 0x80
25#define I2C_ADDR_MSP3400_ALT 0x88
26#define I2C_ADDR_TEA6300 0x80 /* also used by 6320 */
27#define I2C_ADDR_DPL3518 0x84
28#define I2C_ADDR_TDA9887 0x86
29
30/*
31 * i2c bus addresses for the chips supported by tvaudio.c
32 */
33
34#define I2C_ADDR_TDA8425 0x82
35#define I2C_ADDR_TDA9840 0x84 /* also used by TA8874Z */
36#define I2C_ADDR_TDA985x_L 0xb4 /* also used by 9873 */
37#define I2C_ADDR_TDA985x_H 0xb6
38#define I2C_ADDR_TDA9874 0xb0 /* also used by 9875 */
39
40#define I2C_ADDR_TEA6300 0x80 /* also used by 6320 */
41#define I2C_ADDR_TEA6420 0x98
42
43#define I2C_ADDR_PIC16C54 0x96 /* PV951 */
diff --git a/include/media/i2c/as3645a.h b/include/media/i2c/as3645a.h
deleted file mode 100644
index fffd4b563f5a..000000000000
--- a/include/media/i2c/as3645a.h
+++ /dev/null
@@ -1,66 +0,0 @@
1/*
2 * include/media/i2c/as3645a.h
3 *
4 * Copyright (C) 2008-2011 Nokia Corporation
5 *
6 * Contact: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 */
18
19#ifndef __AS3645A_H__
20#define __AS3645A_H__
21
22#include <media/v4l2-subdev.h>
23
24#define AS3645A_NAME "as3645a"
25#define AS3645A_I2C_ADDR (0x60 >> 1) /* W:0x60, R:0x61 */
26
27#define AS3645A_FLASH_TIMEOUT_MIN 100000 /* us */
28#define AS3645A_FLASH_TIMEOUT_MAX 850000
29#define AS3645A_FLASH_TIMEOUT_STEP 50000
30
31#define AS3645A_FLASH_INTENSITY_MIN 200 /* mA */
32#define AS3645A_FLASH_INTENSITY_MAX_1LED 500
33#define AS3645A_FLASH_INTENSITY_MAX_2LEDS 400
34#define AS3645A_FLASH_INTENSITY_STEP 20
35
36#define AS3645A_TORCH_INTENSITY_MIN 20 /* mA */
37#define AS3645A_TORCH_INTENSITY_MAX 160
38#define AS3645A_TORCH_INTENSITY_STEP 20
39
40#define AS3645A_INDICATOR_INTENSITY_MIN 0 /* uA */
41#define AS3645A_INDICATOR_INTENSITY_MAX 10000
42#define AS3645A_INDICATOR_INTENSITY_STEP 2500
43
44/*
45 * as3645a_platform_data - Flash controller platform data
46 * @set_power: Set power callback
47 * @vref: VREF offset (0=0V, 1=+0.3V, 2=-0.3V, 3=+0.6V)
48 * @peak: Inductor peak current limit (0=1.25A, 1=1.5A, 2=1.75A, 3=2.0A)
49 * @ext_strobe: True if external flash strobe can be used
50 * @flash_max_current: Max flash current (mA, <= AS3645A_FLASH_INTENSITY_MAX)
51 * @torch_max_current: Max torch current (mA, >= AS3645A_TORCH_INTENSITY_MAX)
52 * @timeout_max: Max flash timeout (us, <= AS3645A_FLASH_TIMEOUT_MAX)
53 */
54struct as3645a_platform_data {
55 int (*set_power)(struct v4l2_subdev *subdev, int on);
56 unsigned int vref;
57 unsigned int peak;
58 bool ext_strobe;
59
60 /* Flash and torch currents and timeout limits */
61 unsigned int flash_max_current;
62 unsigned int torch_max_current;
63 unsigned int timeout_max;
64};
65
66#endif /* __AS3645A_H__ */
diff --git a/include/media/i2c/bt819.h b/include/media/i2c/bt819.h
index 8025f4bc2bb6..1bcf0dbeb516 100644
--- a/include/media/i2c/bt819.h
+++ b/include/media/i2c/bt819.h
@@ -30,7 +30,7 @@
30 30
31 Note: these ioctls that internal to the kernel and are never called 31 Note: these ioctls that internal to the kernel and are never called
32 from userspace. */ 32 from userspace. */
33#define BT819_FIFO_RESET_LOW _IO('b', 0) 33#define BT819_FIFO_RESET_LOW _IO('b', 0)
34#define BT819_FIFO_RESET_HIGH _IO('b', 1) 34#define BT819_FIFO_RESET_HIGH _IO('b', 1)
35 35
36#endif 36#endif
diff --git a/include/media/i2c/ir-kbd-i2c.h b/include/media/i2c/ir-kbd-i2c.h
index 76491c62c254..9f47d6a48cff 100644
--- a/include/media/i2c/ir-kbd-i2c.h
+++ b/include/media/i2c/ir-kbd-i2c.h
@@ -19,11 +19,15 @@ struct IR_i2c {
19 u32 polling_interval; /* in ms */ 19 u32 polling_interval; /* in ms */
20 20
21 struct delayed_work work; 21 struct delayed_work work;
22 char name[32];
23 char phys[32]; 22 char phys[32];
24 int (*get_key)(struct IR_i2c *ir, 23 int (*get_key)(struct IR_i2c *ir,
25 enum rc_proto *protocol, 24 enum rc_proto *protocol,
26 u32 *scancode, u8 *toggle); 25 u32 *scancode, u8 *toggle);
26 /* tx */
27 struct i2c_client *tx_c;
28 struct mutex lock; /* do not poll Rx during Tx */
29 unsigned int carrier;
30 unsigned int duty_cycle;
27}; 31};
28 32
29enum ir_kbd_get_key_fn { 33enum ir_kbd_get_key_fn {
diff --git a/include/media/i2c/m52790.h b/include/media/i2c/m52790.h
index 7ddffae31a67..8d9db3cf6fab 100644
--- a/include/media/i2c/m52790.h
+++ b/include/media/i2c/m52790.h
@@ -23,57 +23,57 @@
23 23
24/* Input routing switch 1 */ 24/* Input routing switch 1 */
25 25
26#define M52790_SW1_IN_MASK 0x0003 26#define M52790_SW1_IN_MASK 0x0003
27#define M52790_SW1_IN_TUNER 0x0000 27#define M52790_SW1_IN_TUNER 0x0000
28#define M52790_SW1_IN_V2 0x0001 28#define M52790_SW1_IN_V2 0x0001
29#define M52790_SW1_IN_V3 0x0002 29#define M52790_SW1_IN_V3 0x0002
30#define M52790_SW1_IN_V4 0x0003 30#define M52790_SW1_IN_V4 0x0003
31 31
32/* Selects component input instead of composite */ 32/* Selects component input instead of composite */
33#define M52790_SW1_YCMIX 0x0004 33#define M52790_SW1_YCMIX 0x0004
34 34
35 35
36/* Input routing switch 2 */ 36/* Input routing switch 2 */
37 37
38#define M52790_SW2_IN_MASK 0x0300 38#define M52790_SW2_IN_MASK 0x0300
39#define M52790_SW2_IN_TUNER 0x0000 39#define M52790_SW2_IN_TUNER 0x0000
40#define M52790_SW2_IN_V2 0x0100 40#define M52790_SW2_IN_V2 0x0100
41#define M52790_SW2_IN_V3 0x0200 41#define M52790_SW2_IN_V3 0x0200
42#define M52790_SW2_IN_V4 0x0300 42#define M52790_SW2_IN_V4 0x0300
43 43
44/* Selects component input instead of composite */ 44/* Selects component input instead of composite */
45#define M52790_SW2_YCMIX 0x0400 45#define M52790_SW2_YCMIX 0x0400
46 46
47 47
48/* Output routing switch 1 */ 48/* Output routing switch 1 */
49 49
50/* Enable 6dB amplifier for composite out */ 50/* Enable 6dB amplifier for composite out */
51#define M52790_SW1_V_AMP 0x0008 51#define M52790_SW1_V_AMP 0x0008
52 52
53/* Enable 6dB amplifier for component out */ 53/* Enable 6dB amplifier for component out */
54#define M52790_SW1_YC_AMP 0x0010 54#define M52790_SW1_YC_AMP 0x0010
55 55
56/* Audio output mode */ 56/* Audio output mode */
57#define M52790_SW1_AUDIO_MASK 0x00c0 57#define M52790_SW1_AUDIO_MASK 0x00c0
58#define M52790_SW1_AUDIO_MUTE 0x0000 58#define M52790_SW1_AUDIO_MUTE 0x0000
59#define M52790_SW1_AUDIO_R 0x0040 59#define M52790_SW1_AUDIO_R 0x0040
60#define M52790_SW1_AUDIO_L 0x0080 60#define M52790_SW1_AUDIO_L 0x0080
61#define M52790_SW1_AUDIO_STEREO 0x00c0 61#define M52790_SW1_AUDIO_STEREO 0x00c0
62 62
63 63
64/* Output routing switch 2 */ 64/* Output routing switch 2 */
65 65
66/* Enable 6dB amplifier for composite out */ 66/* Enable 6dB amplifier for composite out */
67#define M52790_SW2_V_AMP 0x0800 67#define M52790_SW2_V_AMP 0x0800
68 68
69/* Enable 6dB amplifier for component out */ 69/* Enable 6dB amplifier for component out */
70#define M52790_SW2_YC_AMP 0x1000 70#define M52790_SW2_YC_AMP 0x1000
71 71
72/* Audio output mode */ 72/* Audio output mode */
73#define M52790_SW2_AUDIO_MASK 0xc000 73#define M52790_SW2_AUDIO_MASK 0xc000
74#define M52790_SW2_AUDIO_MUTE 0x0000 74#define M52790_SW2_AUDIO_MUTE 0x0000
75#define M52790_SW2_AUDIO_R 0x4000 75#define M52790_SW2_AUDIO_R 0x4000
76#define M52790_SW2_AUDIO_L 0x8000 76#define M52790_SW2_AUDIO_L 0x8000
77#define M52790_SW2_AUDIO_STEREO 0xc000 77#define M52790_SW2_AUDIO_STEREO 0xc000
78 78
79 79
@@ -83,9 +83,9 @@
83#define M52790_IN_V3 (M52790_SW1_IN_V3 | M52790_SW2_IN_V3) 83#define M52790_IN_V3 (M52790_SW1_IN_V3 | M52790_SW2_IN_V3)
84#define M52790_IN_V4 (M52790_SW1_IN_V4 | M52790_SW2_IN_V4) 84#define M52790_IN_V4 (M52790_SW1_IN_V4 | M52790_SW2_IN_V4)
85 85
86#define M52790_OUT_STEREO (M52790_SW1_AUDIO_STEREO | \ 86#define M52790_OUT_STEREO (M52790_SW1_AUDIO_STEREO | \
87 M52790_SW2_AUDIO_STEREO) 87 M52790_SW2_AUDIO_STEREO)
88#define M52790_OUT_AMP_STEREO (M52790_SW1_AUDIO_STEREO | \ 88#define M52790_OUT_AMP_STEREO (M52790_SW1_AUDIO_STEREO | \
89 M52790_SW1_V_AMP | \ 89 M52790_SW1_V_AMP | \
90 M52790_SW2_AUDIO_STEREO | \ 90 M52790_SW2_AUDIO_STEREO | \
91 M52790_SW2_V_AMP) 91 M52790_SW2_V_AMP)
diff --git a/include/media/i2c/saa7115.h b/include/media/i2c/saa7115.h
index 53954c90e7f6..a0cda423509d 100644
--- a/include/media/i2c/saa7115.h
+++ b/include/media/i2c/saa7115.h
@@ -36,15 +36,15 @@
36#define SAA7115_SVIDEO3 9 36#define SAA7115_SVIDEO3 9
37 37
38/* outputs */ 38/* outputs */
39#define SAA7115_IPORT_ON 1 39#define SAA7115_IPORT_ON 1
40#define SAA7115_IPORT_OFF 0 40#define SAA7115_IPORT_OFF 0
41 41
42/* SAA7111 specific outputs. */ 42/* SAA7111 specific outputs. */
43#define SAA7111_VBI_BYPASS 2 43#define SAA7111_VBI_BYPASS 2
44#define SAA7111_FMT_YUV422 0x00 44#define SAA7111_FMT_YUV422 0x00
45#define SAA7111_FMT_RGB 0x40 45#define SAA7111_FMT_RGB 0x40
46#define SAA7111_FMT_CCIR 0x80 46#define SAA7111_FMT_CCIR 0x80
47#define SAA7111_FMT_YUV411 0xc0 47#define SAA7111_FMT_YUV411 0xc0
48 48
49/* config flags */ 49/* config flags */
50/* 50/*
diff --git a/include/media/i2c/tvaudio.h b/include/media/i2c/tvaudio.h
index 1ac8184693f8..f13e1a386364 100644
--- a/include/media/i2c/tvaudio.h
+++ b/include/media/i2c/tvaudio.h
@@ -21,7 +21,22 @@
21#ifndef _TVAUDIO_H 21#ifndef _TVAUDIO_H
22#define _TVAUDIO_H 22#define _TVAUDIO_H
23 23
24#include <media/i2c-addr.h> 24/*
25 * i2c bus addresses for the chips supported by tvaudio.c
26 */
27
28#define I2C_ADDR_TDA8425 0x82
29#define I2C_ADDR_TDA9840 0x84
30#define I2C_ADDR_TDA9874 0xb0 /* also used by 9875 */
31#define I2C_ADDR_TDA9875 0xb0
32#define I2C_ADDR_TDA8425 0x82
33#define I2C_ADDR_TDA9840 0x84 /* also used by TA8874Z */
34#define I2C_ADDR_TDA985x_L 0xb4 /* also used by 9873 */
35#define I2C_ADDR_TDA985x_H 0xb6
36#define I2C_ADDR_TDA9874 0xb0 /* also used by 9875 */
37#define I2C_ADDR_TEA6300 0x80 /* also used by 6320 */
38#define I2C_ADDR_TEA6420 0x98
39#define I2C_ADDR_PIC16C54 0x96 /* PV951 */
25 40
26/* The tvaudio module accepts the following inputs: */ 41/* The tvaudio module accepts the following inputs: */
27#define TVAUDIO_INPUT_TUNER 0 42#define TVAUDIO_INPUT_TUNER 0
diff --git a/include/media/i2c/upd64031a.h b/include/media/i2c/upd64031a.h
index 48ec03c4ef23..1eba24dfee48 100644
--- a/include/media/i2c/upd64031a.h
+++ b/include/media/i2c/upd64031a.h
@@ -18,9 +18,9 @@
18#define _UPD64031A_H_ 18#define _UPD64031A_H_
19 19
20/* Ghost reduction modes */ 20/* Ghost reduction modes */
21#define UPD64031A_GR_ON 0 21#define UPD64031A_GR_ON 0
22#define UPD64031A_GR_OFF 1 22#define UPD64031A_GR_OFF 1
23#define UPD64031A_GR_THROUGH 3 23#define UPD64031A_GR_THROUGH 3
24 24
25/* Direct 3D/YCS Connection */ 25/* Direct 3D/YCS Connection */
26#define UPD64031A_3DYCS_DISABLE (0 << 2) 26#define UPD64031A_3DYCS_DISABLE (0 << 2)
diff --git a/include/media/lirc.h b/include/media/lirc.h
deleted file mode 100644
index 554988c860c1..000000000000
--- a/include/media/lirc.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <uapi/linux/lirc.h>
diff --git a/include/media/lirc_dev.h b/include/media/lirc_dev.h
deleted file mode 100644
index d9c143d17f70..000000000000
--- a/include/media/lirc_dev.h
+++ /dev/null
@@ -1,192 +0,0 @@
1/*
2 * LIRC base driver
3 *
4 * by Artur Lipowski <alipowski@interia.pl>
5 * This code is licensed under GNU GPL
6 *
7 */
8
9#ifndef _LINUX_LIRC_DEV_H
10#define _LINUX_LIRC_DEV_H
11
12#define BUFLEN 16
13
14#include <linux/slab.h>
15#include <linux/fs.h>
16#include <linux/ioctl.h>
17#include <linux/poll.h>
18#include <linux/kfifo.h>
19#include <media/lirc.h>
20#include <linux/device.h>
21#include <linux/cdev.h>
22
23struct lirc_buffer {
24 wait_queue_head_t wait_poll;
25 spinlock_t fifo_lock;
26 unsigned int chunk_size;
27 unsigned int size; /* in chunks */
28 /* Using chunks instead of bytes pretends to simplify boundary checking
29 * And should allow for some performance fine tunning later */
30 struct kfifo fifo;
31};
32
33static inline void lirc_buffer_clear(struct lirc_buffer *buf)
34{
35 unsigned long flags;
36
37 if (kfifo_initialized(&buf->fifo)) {
38 spin_lock_irqsave(&buf->fifo_lock, flags);
39 kfifo_reset(&buf->fifo);
40 spin_unlock_irqrestore(&buf->fifo_lock, flags);
41 } else
42 WARN(1, "calling %s on an uninitialized lirc_buffer\n",
43 __func__);
44}
45
46static inline int lirc_buffer_init(struct lirc_buffer *buf,
47 unsigned int chunk_size,
48 unsigned int size)
49{
50 int ret;
51
52 init_waitqueue_head(&buf->wait_poll);
53 spin_lock_init(&buf->fifo_lock);
54 buf->chunk_size = chunk_size;
55 buf->size = size;
56 ret = kfifo_alloc(&buf->fifo, size * chunk_size, GFP_KERNEL);
57
58 return ret;
59}
60
61static inline void lirc_buffer_free(struct lirc_buffer *buf)
62{
63 if (kfifo_initialized(&buf->fifo)) {
64 kfifo_free(&buf->fifo);
65 } else
66 WARN(1, "calling %s on an uninitialized lirc_buffer\n",
67 __func__);
68}
69
70static inline int lirc_buffer_len(struct lirc_buffer *buf)
71{
72 int len;
73 unsigned long flags;
74
75 spin_lock_irqsave(&buf->fifo_lock, flags);
76 len = kfifo_len(&buf->fifo);
77 spin_unlock_irqrestore(&buf->fifo_lock, flags);
78
79 return len;
80}
81
82static inline int lirc_buffer_full(struct lirc_buffer *buf)
83{
84 return lirc_buffer_len(buf) == buf->size * buf->chunk_size;
85}
86
87static inline int lirc_buffer_empty(struct lirc_buffer *buf)
88{
89 return !lirc_buffer_len(buf);
90}
91
92static inline unsigned int lirc_buffer_read(struct lirc_buffer *buf,
93 unsigned char *dest)
94{
95 unsigned int ret = 0;
96
97 if (lirc_buffer_len(buf) >= buf->chunk_size)
98 ret = kfifo_out_locked(&buf->fifo, dest, buf->chunk_size,
99 &buf->fifo_lock);
100 return ret;
101
102}
103
104static inline unsigned int lirc_buffer_write(struct lirc_buffer *buf,
105 unsigned char *orig)
106{
107 unsigned int ret;
108
109 ret = kfifo_in_locked(&buf->fifo, orig, buf->chunk_size,
110 &buf->fifo_lock);
111
112 return ret;
113}
114
115/**
116 * struct lirc_dev - represents a LIRC device
117 *
118 * @name: used for logging
119 * @minor: the minor device (/dev/lircX) number for the device
120 * @code_length: length of a remote control key code expressed in bits
121 * @features: lirc compatible hardware features, like LIRC_MODE_RAW,
122 * LIRC_CAN\_\*, as defined at include/media/lirc.h.
123 * @buffer_size: Number of FIFO buffers with @chunk_size size.
124 * Only used if @rbuf is NULL.
125 * @chunk_size: Size of each FIFO buffer.
126 * Only used if @rbuf is NULL.
127 * @data: private per-driver data
128 * @buf: if %NULL, lirc_dev will allocate and manage the buffer,
129 * otherwise allocated by the caller which will
130 * have to write to the buffer by other means, like irq's
131 * (see also lirc_serial.c).
132 * @buf_internal: whether lirc_dev has allocated the read buffer or not
133 * @rdev: &struct rc_dev associated with the device
134 * @fops: &struct file_operations for the device
135 * @owner: the module owning this struct
136 * @attached: if the device is still live
137 * @open: open count for the device's chardev
138 * @mutex: serialises file_operations calls
139 * @dev: &struct device assigned to the device
140 * @cdev: &struct cdev assigned to the device
141 */
142struct lirc_dev {
143 char name[40];
144 unsigned int minor;
145 __u32 code_length;
146 __u32 features;
147
148 unsigned int buffer_size; /* in chunks holding one code each */
149 unsigned int chunk_size;
150 struct lirc_buffer *buf;
151 bool buf_internal;
152
153 void *data;
154 struct rc_dev *rdev;
155 const struct file_operations *fops;
156 struct module *owner;
157
158 bool attached;
159 int open;
160
161 struct mutex mutex; /* protect from simultaneous accesses */
162
163 struct device dev;
164 struct cdev cdev;
165};
166
167struct lirc_dev *lirc_allocate_device(void);
168
169void lirc_free_device(struct lirc_dev *d);
170
171int lirc_register_device(struct lirc_dev *d);
172
173void lirc_unregister_device(struct lirc_dev *d);
174
175/* Must be called in the open fop before lirc_get_pdata() can be used */
176void lirc_init_pdata(struct inode *inode, struct file *file);
177
178/* Returns the private data stored in the lirc_dev
179 * associated with the given device file pointer.
180 */
181void *lirc_get_pdata(struct file *file);
182
183/* default file operations
184 * used by drivers if they override only some operations
185 */
186int lirc_dev_fop_open(struct inode *inode, struct file *file);
187int lirc_dev_fop_close(struct inode *inode, struct file *file);
188__poll_t lirc_dev_fop_poll(struct file *file, poll_table *wait);
189long lirc_dev_fop_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
190ssize_t lirc_dev_fop_read(struct file *file, char __user *buffer, size_t length,
191 loff_t *ppos);
192#endif
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index 222d379960b7..a732af1dbba0 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -88,6 +88,8 @@ struct media_entity_enum {
88 * @stack: Graph traversal stack; the stack contains information 88 * @stack: Graph traversal stack; the stack contains information
89 * on the path the media entities to be walked and the 89 * on the path the media entities to be walked and the
90 * links through which they were reached. 90 * links through which they were reached.
91 * @stack.entity: pointer to &struct media_entity at the graph.
92 * @stack.link: pointer to &struct list_head.
91 * @ent_enum: Visited entities 93 * @ent_enum: Visited entities
92 * @top: The top of the stack 94 * @top: The top of the stack
93 */ 95 */
@@ -247,6 +249,9 @@ enum media_entity_type {
247 * @pipe: Pipeline this entity belongs to. 249 * @pipe: Pipeline this entity belongs to.
248 * @info: Union with devnode information. Kept just for backward 250 * @info: Union with devnode information. Kept just for backward
249 * compatibility. 251 * compatibility.
252 * @info.dev: Contains device major and minor info.
253 * @info.dev.major: device node major, if the device is a devnode.
254 * @info.dev.minor: device node minor, if the device is a devnode.
250 * @major: Devnode major number (zero if not applicable). Kept just 255 * @major: Devnode major number (zero if not applicable). Kept just
251 * for backward compatibility. 256 * for backward compatibility.
252 * @minor: Devnode minor number (zero if not applicable). Kept just 257 * @minor: Devnode minor number (zero if not applicable). Kept just
@@ -629,7 +634,11 @@ int media_entity_pads_init(struct media_entity *entity, u16 num_pads,
629 * This function must be called during the cleanup phase after unregistering 634 * This function must be called during the cleanup phase after unregistering
630 * the entity (currently, it does nothing). 635 * the entity (currently, it does nothing).
631 */ 636 */
632static inline void media_entity_cleanup(struct media_entity *entity) {}; 637#if IS_ENABLED(CONFIG_MEDIA_CONTROLLER)
638static inline void media_entity_cleanup(struct media_entity *entity) {}
639#else
640#define media_entity_cleanup(entity) do { } while (false)
641#endif
633 642
634/** 643/**
635 * media_create_pad_link() - creates a link between two entities. 644 * media_create_pad_link() - creates a link between two entities.
diff --git a/include/media/rc-core.h b/include/media/rc-core.h
index 314a1edb6189..aed4272d47f5 100644
--- a/include/media/rc-core.h
+++ b/include/media/rc-core.h
@@ -17,6 +17,7 @@
17#define _RC_CORE 17#define _RC_CORE
18 18
19#include <linux/spinlock.h> 19#include <linux/spinlock.h>
20#include <linux/cdev.h>
20#include <linux/kfifo.h> 21#include <linux/kfifo.h>
21#include <linux/time.h> 22#include <linux/time.h>
22#include <linux/timer.h> 23#include <linux/timer.h>
@@ -30,9 +31,9 @@ do { \
30} while (0) 31} while (0)
31 32
32/** 33/**
33 * enum rc_driver_type - type of the RC output 34 * enum rc_driver_type - type of the RC driver.
34 * 35 *
35 * @RC_DRIVER_SCANCODE: Driver or hardware generates a scancode 36 * @RC_DRIVER_SCANCODE: Driver or hardware generates a scancode.
36 * @RC_DRIVER_IR_RAW: Driver or hardware generates pulse/space sequences. 37 * @RC_DRIVER_IR_RAW: Driver or hardware generates pulse/space sequences.
37 * It needs a Infra-Red pulse/space decoder 38 * It needs a Infra-Red pulse/space decoder
38 * @RC_DRIVER_IR_RAW_TX: Device transmitter only, 39 * @RC_DRIVER_IR_RAW_TX: Device transmitter only,
@@ -68,6 +69,33 @@ enum rc_filter_type {
68}; 69};
69 70
70/** 71/**
72 * struct lirc_fh - represents an open lirc file
73 * @list: list of open file handles
74 * @rc: rcdev for this lirc chardev
75 * @carrier_low: when setting the carrier range, first the low end must be
76 * set with an ioctl and then the high end with another ioctl
77 * @send_timeout_reports: report timeouts in lirc raw IR.
78 * @rawir: queue for incoming raw IR
79 * @scancodes: queue for incoming decoded scancodes
80 * @wait_poll: poll struct for lirc device
81 * @send_mode: lirc mode for sending, either LIRC_MODE_SCANCODE or
82 * LIRC_MODE_PULSE
83 * @rec_mode: lirc mode for receiving, either LIRC_MODE_SCANCODE or
84 * LIRC_MODE_MODE2
85 */
86struct lirc_fh {
87 struct list_head list;
88 struct rc_dev *rc;
89 int carrier_low;
90 bool send_timeout_reports;
91 DECLARE_KFIFO_PTR(rawir, unsigned int);
92 DECLARE_KFIFO_PTR(scancodes, struct lirc_scancode);
93 wait_queue_head_t wait_poll;
94 u8 send_mode;
95 u8 rec_mode;
96};
97
98/**
71 * struct rc_dev - represents a remote control device 99 * struct rc_dev - represents a remote control device
72 * @dev: driver model's view of this device 100 * @dev: driver model's view of this device
73 * @managed_alloc: devm_rc_allocate_device was used to create rc_dev 101 * @managed_alloc: devm_rc_allocate_device was used to create rc_dev
@@ -106,6 +134,8 @@ enum rc_filter_type {
106 * @keypressed: whether a key is currently pressed 134 * @keypressed: whether a key is currently pressed
107 * @keyup_jiffies: time (in jiffies) when the current keypress should be released 135 * @keyup_jiffies: time (in jiffies) when the current keypress should be released
108 * @timer_keyup: timer for releasing a keypress 136 * @timer_keyup: timer for releasing a keypress
137 * @timer_repeat: timer for autorepeat events. This is needed for CEC, which
138 * has non-standard repeats.
109 * @last_keycode: keycode of last keypress 139 * @last_keycode: keycode of last keypress
110 * @last_protocol: protocol of last keypress 140 * @last_protocol: protocol of last keypress
111 * @last_scancode: scancode of last keypress 141 * @last_scancode: scancode of last keypress
@@ -115,6 +145,15 @@ enum rc_filter_type {
115 * @max_timeout: maximum timeout supported by device 145 * @max_timeout: maximum timeout supported by device
116 * @rx_resolution : resolution (in ns) of input sampler 146 * @rx_resolution : resolution (in ns) of input sampler
117 * @tx_resolution: resolution (in ns) of output sampler 147 * @tx_resolution: resolution (in ns) of output sampler
148 * @lirc_dev: lirc device
149 * @lirc_cdev: lirc char cdev
150 * @gap_start: time when gap starts
151 * @gap_duration: duration of initial gap
152 * @gap: true if we're in a gap
153 * @lirc_fh_lock: protects lirc_fh list
154 * @lirc_fh: list of open files
155 * @registered: set to true by rc_register_device(), false by
156 * rc_unregister_device
118 * @change_protocol: allow changing the protocol used on hardware decoders 157 * @change_protocol: allow changing the protocol used on hardware decoders
119 * @open: callback to allow drivers to enable polling/irq when IR input device 158 * @open: callback to allow drivers to enable polling/irq when IR input device
120 * is opened. 159 * is opened.
@@ -165,6 +204,7 @@ struct rc_dev {
165 bool keypressed; 204 bool keypressed;
166 unsigned long keyup_jiffies; 205 unsigned long keyup_jiffies;
167 struct timer_list timer_keyup; 206 struct timer_list timer_keyup;
207 struct timer_list timer_repeat;
168 u32 last_keycode; 208 u32 last_keycode;
169 enum rc_proto last_protocol; 209 enum rc_proto last_protocol;
170 u32 last_scancode; 210 u32 last_scancode;
@@ -174,6 +214,16 @@ struct rc_dev {
174 u32 max_timeout; 214 u32 max_timeout;
175 u32 rx_resolution; 215 u32 rx_resolution;
176 u32 tx_resolution; 216 u32 tx_resolution;
217#ifdef CONFIG_LIRC
218 struct device lirc_dev;
219 struct cdev lirc_cdev;
220 ktime_t gap_start;
221 u64 gap_duration;
222 bool gap;
223 spinlock_t lirc_fh_lock;
224 struct list_head lirc_fh;
225#endif
226 bool registered;
177 int (*change_protocol)(struct rc_dev *dev, u64 *rc_proto); 227 int (*change_protocol)(struct rc_dev *dev, u64 *rc_proto);
178 int (*open)(struct rc_dev *dev); 228 int (*open)(struct rc_dev *dev);
179 void (*close)(struct rc_dev *dev); 229 void (*close)(struct rc_dev *dev);
@@ -248,20 +298,6 @@ int devm_rc_register_device(struct device *parent, struct rc_dev *dev);
248 */ 298 */
249void rc_unregister_device(struct rc_dev *dev); 299void rc_unregister_device(struct rc_dev *dev);
250 300
251/**
252 * rc_open - Opens a RC device
253 *
254 * @rdev: pointer to struct rc_dev.
255 */
256int rc_open(struct rc_dev *rdev);
257
258/**
259 * rc_close - Closes a RC device
260 *
261 * @rdev: pointer to struct rc_dev.
262 */
263void rc_close(struct rc_dev *rdev);
264
265void rc_repeat(struct rc_dev *dev); 301void rc_repeat(struct rc_dev *dev);
266void rc_keydown(struct rc_dev *dev, enum rc_proto protocol, u32 scancode, 302void rc_keydown(struct rc_dev *dev, enum rc_proto protocol, u32 scancode,
267 u8 toggle); 303 u8 toggle);
@@ -309,6 +345,7 @@ int ir_raw_event_store_with_filter(struct rc_dev *dev,
309void ir_raw_event_set_idle(struct rc_dev *dev, bool idle); 345void ir_raw_event_set_idle(struct rc_dev *dev, bool idle);
310int ir_raw_encode_scancode(enum rc_proto protocol, u32 scancode, 346int ir_raw_encode_scancode(enum rc_proto protocol, u32 scancode,
311 struct ir_raw_event *events, unsigned int max); 347 struct ir_raw_event *events, unsigned int max);
348int ir_raw_encode_carrier(enum rc_proto protocol);
312 349
313static inline void ir_raw_event_reset(struct rc_dev *dev) 350static inline void ir_raw_event_reset(struct rc_dev *dev)
314{ 351{
diff --git a/include/media/rc-map.h b/include/media/rc-map.h
index 72197cb43781..7046734b3895 100644
--- a/include/media/rc-map.h
+++ b/include/media/rc-map.h
@@ -10,59 +10,7 @@
10 */ 10 */
11 11
12#include <linux/input.h> 12#include <linux/input.h>
13 13#include <uapi/linux/lirc.h>
14/**
15 * enum rc_proto - the Remote Controller protocol
16 *
17 * @RC_PROTO_UNKNOWN: Protocol not known
18 * @RC_PROTO_OTHER: Protocol known but proprietary
19 * @RC_PROTO_RC5: Philips RC5 protocol
20 * @RC_PROTO_RC5X_20: Philips RC5x 20 bit protocol
21 * @RC_PROTO_RC5_SZ: StreamZap variant of RC5
22 * @RC_PROTO_JVC: JVC protocol
23 * @RC_PROTO_SONY12: Sony 12 bit protocol
24 * @RC_PROTO_SONY15: Sony 15 bit protocol
25 * @RC_PROTO_SONY20: Sony 20 bit protocol
26 * @RC_PROTO_NEC: NEC protocol
27 * @RC_PROTO_NECX: Extended NEC protocol
28 * @RC_PROTO_NEC32: NEC 32 bit protocol
29 * @RC_PROTO_SANYO: Sanyo protocol
30 * @RC_PROTO_MCIR2_KBD: RC6-ish MCE keyboard
31 * @RC_PROTO_MCIR2_MSE: RC6-ish MCE mouse
32 * @RC_PROTO_RC6_0: Philips RC6-0-16 protocol
33 * @RC_PROTO_RC6_6A_20: Philips RC6-6A-20 protocol
34 * @RC_PROTO_RC6_6A_24: Philips RC6-6A-24 protocol
35 * @RC_PROTO_RC6_6A_32: Philips RC6-6A-32 protocol
36 * @RC_PROTO_RC6_MCE: MCE (Philips RC6-6A-32 subtype) protocol
37 * @RC_PROTO_SHARP: Sharp protocol
38 * @RC_PROTO_XMP: XMP protocol
39 * @RC_PROTO_CEC: CEC protocol
40 */
41enum rc_proto {
42 RC_PROTO_UNKNOWN = 0,
43 RC_PROTO_OTHER = 1,
44 RC_PROTO_RC5 = 2,
45 RC_PROTO_RC5X_20 = 3,
46 RC_PROTO_RC5_SZ = 4,
47 RC_PROTO_JVC = 5,
48 RC_PROTO_SONY12 = 6,
49 RC_PROTO_SONY15 = 7,
50 RC_PROTO_SONY20 = 8,
51 RC_PROTO_NEC = 9,
52 RC_PROTO_NECX = 10,
53 RC_PROTO_NEC32 = 11,
54 RC_PROTO_SANYO = 12,
55 RC_PROTO_MCIR2_KBD = 13,
56 RC_PROTO_MCIR2_MSE = 14,
57 RC_PROTO_RC6_0 = 15,
58 RC_PROTO_RC6_6A_20 = 16,
59 RC_PROTO_RC6_6A_24 = 17,
60 RC_PROTO_RC6_6A_32 = 18,
61 RC_PROTO_RC6_MCE = 19,
62 RC_PROTO_SHARP = 20,
63 RC_PROTO_XMP = 21,
64 RC_PROTO_CEC = 22,
65};
66 14
67#define RC_PROTO_BIT_NONE 0ULL 15#define RC_PROTO_BIT_NONE 0ULL
68#define RC_PROTO_BIT_UNKNOWN BIT_ULL(RC_PROTO_UNKNOWN) 16#define RC_PROTO_BIT_UNKNOWN BIT_ULL(RC_PROTO_UNKNOWN)
diff --git a/include/media/v4l2-tpg.h b/include/media/tpg/v4l2-tpg.h
index 13e49d85cae3..823fadede7bf 100644
--- a/include/media/v4l2-tpg.h
+++ b/include/media/tpg/v4l2-tpg.h
@@ -26,8 +26,51 @@
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/vmalloc.h> 27#include <linux/vmalloc.h>
28#include <linux/videodev2.h> 28#include <linux/videodev2.h>
29#include <media/v4l2-tpg-colors.h>
30 29
30struct tpg_rbg_color8 {
31 unsigned char r, g, b;
32};
33
34struct tpg_rbg_color16 {
35 __u16 r, g, b;
36};
37
38enum tpg_color {
39 TPG_COLOR_CSC_WHITE,
40 TPG_COLOR_CSC_YELLOW,
41 TPG_COLOR_CSC_CYAN,
42 TPG_COLOR_CSC_GREEN,
43 TPG_COLOR_CSC_MAGENTA,
44 TPG_COLOR_CSC_RED,
45 TPG_COLOR_CSC_BLUE,
46 TPG_COLOR_CSC_BLACK,
47 TPG_COLOR_75_YELLOW,
48 TPG_COLOR_75_CYAN,
49 TPG_COLOR_75_GREEN,
50 TPG_COLOR_75_MAGENTA,
51 TPG_COLOR_75_RED,
52 TPG_COLOR_75_BLUE,
53 TPG_COLOR_100_WHITE,
54 TPG_COLOR_100_YELLOW,
55 TPG_COLOR_100_CYAN,
56 TPG_COLOR_100_GREEN,
57 TPG_COLOR_100_MAGENTA,
58 TPG_COLOR_100_RED,
59 TPG_COLOR_100_BLUE,
60 TPG_COLOR_100_BLACK,
61 TPG_COLOR_TEXTFG,
62 TPG_COLOR_TEXTBG,
63 TPG_COLOR_RANDOM,
64 TPG_COLOR_RAMP,
65 TPG_COLOR_MAX = TPG_COLOR_RAMP + 256
66};
67
68extern const struct tpg_rbg_color8 tpg_colors[TPG_COLOR_MAX];
69extern const unsigned short tpg_rec709_to_linear[255 * 16 + 1];
70extern const unsigned short tpg_linear_to_rec709[255 * 16 + 1];
71extern const struct tpg_rbg_color16 tpg_csc_colors[V4L2_COLORSPACE_DCI_P3 + 1]
72 [V4L2_XFER_FUNC_SMPTE2084 + 1]
73 [TPG_COLOR_CSC_BLACK + 1];
31enum tpg_pattern { 74enum tpg_pattern {
32 TPG_PAT_75_COLORBAR, 75 TPG_PAT_75_COLORBAR,
33 TPG_PAT_100_COLORBAR, 76 TPG_PAT_100_COLORBAR,
diff --git a/include/media/tuner-types.h b/include/media/tuner-types.h
index 78f0654d9c3d..df76ac8e658c 100644
--- a/include/media/tuner-types.h
+++ b/include/media/tuner-types.h
@@ -171,6 +171,21 @@ struct tuner_params {
171 struct tuner_range *ranges; 171 struct tuner_range *ranges;
172}; 172};
173 173
174/**
175 * struct tunertype - describes the known tuners.
176 *
177 * @name: string with the tuner's name.
178 * @count: size of &struct tuner_params array.
179 * @params: pointer to &struct tuner_params array.
180 *
181 * @min: minimal tuner frequency, in 62.5 kHz step.
182 * should be multiplied to 16 to convert to MHz.
183 * @max: minimal tuner frequency, in 62.5 kHz step.
184 * Should be multiplied to 16 to convert to MHz.
185 * @stepsize: frequency step, in Hz.
186 * @initdata: optional byte sequence to initialize the tuner.
187 * @sleepdata: optional byte sequence to power down the tuner.
188 */
174struct tunertype { 189struct tunertype {
175 char *name; 190 char *name;
176 unsigned int count; 191 unsigned int count;
diff --git a/include/media/v4l2-async.h b/include/media/v4l2-async.h
index 6152434cbe82..1592d323c577 100644
--- a/include/media/v4l2-async.h
+++ b/include/media/v4l2-async.h
@@ -28,7 +28,7 @@ struct v4l2_async_notifier;
28 * in order to identify a match 28 * in order to identify a match
29 * 29 *
30 * @V4L2_ASYNC_MATCH_CUSTOM: Match will use the logic provided by &struct 30 * @V4L2_ASYNC_MATCH_CUSTOM: Match will use the logic provided by &struct
31 * v4l2_async_subdev.match ops 31 * v4l2_async_subdev.match ops
32 * @V4L2_ASYNC_MATCH_DEVNAME: Match will use the device name 32 * @V4L2_ASYNC_MATCH_DEVNAME: Match will use the device name
33 * @V4L2_ASYNC_MATCH_I2C: Match will check for I2C adapter ID and address 33 * @V4L2_ASYNC_MATCH_I2C: Match will check for I2C adapter ID and address
34 * @V4L2_ASYNC_MATCH_FWNODE: Match will use firmware node 34 * @V4L2_ASYNC_MATCH_FWNODE: Match will use firmware node
@@ -48,6 +48,31 @@ enum v4l2_async_match_type {
48 * 48 *
49 * @match_type: type of match that will be used 49 * @match_type: type of match that will be used
50 * @match: union of per-bus type matching data sets 50 * @match: union of per-bus type matching data sets
51 * @match.fwnode:
52 * pointer to &struct fwnode_handle to be matched.
53 * Used if @match_type is %V4L2_ASYNC_MATCH_FWNODE.
54 * @match.device_name:
55 * string containing the device name to be matched.
56 * Used if @match_type is %V4L2_ASYNC_MATCH_DEVNAME.
57 * @match.i2c: embedded struct with I2C parameters to be matched.
58 * Both @match.i2c.adapter_id and @match.i2c.address
59 * should be matched.
60 * Used if @match_type is %V4L2_ASYNC_MATCH_I2C.
61 * @match.i2c.adapter_id:
62 * I2C adapter ID to be matched.
63 * Used if @match_type is %V4L2_ASYNC_MATCH_I2C.
64 * @match.i2c.address:
65 * I2C address to be matched.
66 * Used if @match_type is %V4L2_ASYNC_MATCH_I2C.
67 * @match.custom:
68 * Driver-specific match criteria.
69 * Used if @match_type is %V4L2_ASYNC_MATCH_CUSTOM.
70 * @match.custom.match:
71 * Driver-specific match function to be used if
72 * %V4L2_ASYNC_MATCH_CUSTOM.
73 * @match.custom.priv:
74 * Driver-specific private struct with match parameters
75 * to be used if %V4L2_ASYNC_MATCH_CUSTOM.
51 * @list: used to link struct v4l2_async_subdev objects, waiting to be 76 * @list: used to link struct v4l2_async_subdev objects, waiting to be
52 * probed, to a notifier->waiting list 77 * probed, to a notifier->waiting list
53 * 78 *
@@ -58,12 +83,8 @@ enum v4l2_async_match_type {
58struct v4l2_async_subdev { 83struct v4l2_async_subdev {
59 enum v4l2_async_match_type match_type; 84 enum v4l2_async_match_type match_type;
60 union { 85 union {
61 struct { 86 struct fwnode_handle *fwnode;
62 struct fwnode_handle *fwnode; 87 const char *device_name;
63 } fwnode;
64 struct {
65 const char *name;
66 } device_name;
67 struct { 88 struct {
68 int adapter_id; 89 int adapter_id;
69 unsigned short address; 90 unsigned short address;
@@ -167,7 +188,7 @@ void v4l2_async_notifier_cleanup(struct v4l2_async_notifier *notifier);
167 188
168/** 189/**
169 * v4l2_async_register_subdev - registers a sub-device to the asynchronous 190 * v4l2_async_register_subdev - registers a sub-device to the asynchronous
170 * subdevice framework 191 * subdevice framework
171 * 192 *
172 * @sd: pointer to &struct v4l2_subdev 193 * @sd: pointer to &struct v4l2_subdev
173 */ 194 */
@@ -197,7 +218,7 @@ int __must_check v4l2_async_register_subdev_sensor_common(
197 218
198/** 219/**
199 * v4l2_async_unregister_subdev - unregisters a sub-device to the asynchronous 220 * v4l2_async_unregister_subdev - unregisters a sub-device to the asynchronous
200 * subdevice framework 221 * subdevice framework
201 * 222 *
202 * @sd: pointer to &struct v4l2_subdev 223 * @sd: pointer to &struct v4l2_subdev
203 */ 224 */
diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
index aac8b7b6e691..e0d95a7c5d48 100644
--- a/include/media/v4l2-common.h
+++ b/include/media/v4l2-common.h
@@ -28,7 +28,7 @@
28 28
29#include <media/v4l2-dev.h> 29#include <media/v4l2-dev.h>
30 30
31/* Common printk constucts for v4l-i2c drivers. These macros create a unique 31/* Common printk constructs for v4l-i2c drivers. These macros create a unique
32 prefix consisting of the driver name, the adapter number and the i2c 32 prefix consisting of the driver name, the adapter number and the i2c
33 address. */ 33 address. */
34#define v4l_printk(level, name, adapter, addr, fmt, arg...) \ 34#define v4l_printk(level, name, adapter, addr, fmt, arg...) \
@@ -50,7 +50,7 @@
50/* These three macros assume that the debug level is set with a module 50/* These three macros assume that the debug level is set with a module
51 parameter called 'debug'. */ 51 parameter called 'debug'. */
52#define v4l_dbg(level, debug, client, fmt, arg...) \ 52#define v4l_dbg(level, debug, client, fmt, arg...) \
53 do { \ 53 do { \
54 if (debug >= (level)) \ 54 if (debug >= (level)) \
55 v4l_client_printk(KERN_DEBUG, client, fmt , ## arg); \ 55 v4l_client_printk(KERN_DEBUG, client, fmt , ## arg); \
56 } while (0) 56 } while (0)
@@ -80,9 +80,9 @@
80/* These three macros assume that the debug level is set with a module 80/* These three macros assume that the debug level is set with a module
81 parameter called 'debug'. */ 81 parameter called 'debug'. */
82#define v4l2_dbg(level, debug, dev, fmt, arg...) \ 82#define v4l2_dbg(level, debug, dev, fmt, arg...) \
83 do { \ 83 do { \
84 if (debug >= (level)) \ 84 if (debug >= (level)) \
85 v4l2_printk(KERN_DEBUG, dev, fmt , ## arg); \ 85 v4l2_printk(KERN_DEBUG, dev, fmt , ## arg); \
86 } while (0) 86 } while (0)
87 87
88/** 88/**
@@ -127,7 +127,7 @@ struct v4l2_subdev_ops;
127 * @client_type: name of the chip that's on the adapter. 127 * @client_type: name of the chip that's on the adapter.
128 * @addr: I2C address. If zero, it will use @probe_addrs 128 * @addr: I2C address. If zero, it will use @probe_addrs
129 * @probe_addrs: array with a list of address. The last entry at such 129 * @probe_addrs: array with a list of address. The last entry at such
130 * array should be %I2C_CLIENT_END. 130 * array should be %I2C_CLIENT_END.
131 * 131 *
132 * returns a &struct v4l2_subdev pointer. 132 * returns a &struct v4l2_subdev pointer.
133 */ 133 */
@@ -146,7 +146,7 @@ struct i2c_board_info;
146 * @info: pointer to struct i2c_board_info used to replace the irq, 146 * @info: pointer to struct i2c_board_info used to replace the irq,
147 * platform_data and addr arguments. 147 * platform_data and addr arguments.
148 * @probe_addrs: array with a list of address. The last entry at such 148 * @probe_addrs: array with a list of address. The last entry at such
149 * array should be %I2C_CLIENT_END. 149 * array should be %I2C_CLIENT_END.
150 * 150 *
151 * returns a &struct v4l2_subdev pointer. 151 * returns a &struct v4l2_subdev pointer.
152 */ 152 */
@@ -174,17 +174,43 @@ void v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client,
174 */ 174 */
175unsigned short v4l2_i2c_subdev_addr(struct v4l2_subdev *sd); 175unsigned short v4l2_i2c_subdev_addr(struct v4l2_subdev *sd);
176 176
177/**
178 * enum v4l2_i2c_tuner_type - specifies the range of tuner address that
179 * should be used when seeking for I2C devices.
180 *
181 * @ADDRS_RADIO: Radio tuner addresses.
182 * Represent the following I2C addresses:
183 * 0x10 (if compiled with tea5761 support)
184 * and 0x60.
185 * @ADDRS_DEMOD: Demod tuner addresses.
186 * Represent the following I2C addresses:
187 * 0x42, 0x43, 0x4a and 0x4b.
188 * @ADDRS_TV: TV tuner addresses.
189 * Represent the following I2C addresses:
190 * 0x42, 0x43, 0x4a, 0x4b, 0x60, 0x61, 0x62,
191 * 0x63 and 0x64.
192 * @ADDRS_TV_WITH_DEMOD: TV tuner addresses if demod is present, this
193 * excludes addresses used by the demodulator
194 * from the list of candidates.
195 * Represent the following I2C addresses:
196 * 0x60, 0x61, 0x62, 0x63 and 0x64.
197 *
198 * NOTE: All I2C addresses above use the 7-bit notation.
199 */
177enum v4l2_i2c_tuner_type { 200enum v4l2_i2c_tuner_type {
178 ADDRS_RADIO, /* Radio tuner addresses */ 201 ADDRS_RADIO,
179 ADDRS_DEMOD, /* Demod tuner addresses */ 202 ADDRS_DEMOD,
180 ADDRS_TV, /* TV tuner addresses */ 203 ADDRS_TV,
181 /* TV tuner addresses if demod is present, this excludes
182 addresses used by the demodulator from the list of
183 candidates. */
184 ADDRS_TV_WITH_DEMOD, 204 ADDRS_TV_WITH_DEMOD,
185}; 205};
186/* Return a list of I2C tuner addresses to probe. Use only if the tuner 206/**
187 addresses are unknown. */ 207 * v4l2_i2c_tuner_addrs - Return a list of I2C tuner addresses to probe.
208 *
209 * @type: type of the tuner to seek, as defined by
210 * &enum v4l2_i2c_tuner_type.
211 *
212 * NOTE: Use only if the tuner addresses are unknown.
213 */
188const unsigned short *v4l2_i2c_tuner_addrs(enum v4l2_i2c_tuner_type type); 214const unsigned short *v4l2_i2c_tuner_addrs(enum v4l2_i2c_tuner_type type);
189 215
190/* ------------------------------------------------------------------------- */ 216/* ------------------------------------------------------------------------- */
@@ -224,10 +250,14 @@ void v4l2_spi_subdev_init(struct v4l2_subdev *sd, struct spi_device *spi,
224 250
225/* ------------------------------------------------------------------------- */ 251/* ------------------------------------------------------------------------- */
226 252
227/* Note: these remaining ioctls/structs should be removed as well, but they are 253/*
228 still used in tuner-simple.c (TUNER_SET_CONFIG), cx18/ivtv (RESET) and 254 * FIXME: these remaining ioctls/structs should be removed as well, but they
229 v4l2-int-device.h (v4l2_routing). To remove these ioctls some more cleanup 255 * are still used in tuner-simple.c (TUNER_SET_CONFIG) and cx18/ivtv (RESET).
230 is needed in those modules. */ 256 * To remove these ioctls some more cleanup is needed in those modules.
257 *
258 * It doesn't make much sense on documenting them, as what we really want is
259 * to get rid of them.
260 */
231 261
232/* s_config */ 262/* s_config */
233struct v4l2_priv_tun_config { 263struct v4l2_priv_tun_config {
@@ -236,32 +266,79 @@ struct v4l2_priv_tun_config {
236}; 266};
237#define TUNER_SET_CONFIG _IOW('d', 92, struct v4l2_priv_tun_config) 267#define TUNER_SET_CONFIG _IOW('d', 92, struct v4l2_priv_tun_config)
238 268
239#define VIDIOC_INT_RESET _IOW ('d', 102, u32) 269#define VIDIOC_INT_RESET _IOW ('d', 102, u32)
240
241struct v4l2_routing {
242 u32 input;
243 u32 output;
244};
245 270
246/* ------------------------------------------------------------------------- */ 271/* ------------------------------------------------------------------------- */
247 272
248/* Miscellaneous helper functions */ 273/* Miscellaneous helper functions */
249 274
250void v4l_bound_align_image(unsigned int *w, unsigned int wmin, 275/**
276 * v4l_bound_align_image - adjust video dimensions according to
277 * a given constraints.
278 *
279 * @width: pointer to width that will be adjusted if needed.
280 * @wmin: minimum width.
281 * @wmax: maximum width.
282 * @walign: least significant bit on width.
283 * @height: pointer to height that will be adjusted if needed.
284 * @hmin: minimum height.
285 * @hmax: maximum height.
286 * @halign: least significant bit on width.
287 * @salign: least significant bit for the image size (e. g.
288 * :math:`width * height`).
289 *
290 * Clip an image to have @width between @wmin and @wmax, and @height between
291 * @hmin and @hmax, inclusive.
292 *
293 * Additionally, the @width will be a multiple of :math:`2^{walign}`,
294 * the @height will be a multiple of :math:`2^{halign}`, and the overall
295 * size :math:`width * height` will be a multiple of :math:`2^{salign}`.
296 *
297 * .. note::
298 *
299 * #. The clipping rectangle may be shrunk or enlarged to fit the alignment
300 * constraints.
301 * #. @wmax must not be smaller than @wmin.
302 * #. @hmax must not be smaller than @hmin.
303 * #. The alignments must not be so high there are no possible image
304 * sizes within the allowed bounds.
305 * #. @wmin and @hmin must be at least 1 (don't use 0).
306 * #. For @walign, @halign and @salign, if you don't care about a certain
307 * alignment, specify ``0``, as :math:`2^0 = 1` and one byte alignment
308 * is equivalent to no alignment.
309 * #. If you only want to adjust downward, specify a maximum that's the
310 * same as the initial value.
311 */
312void v4l_bound_align_image(unsigned int *width, unsigned int wmin,
251 unsigned int wmax, unsigned int walign, 313 unsigned int wmax, unsigned int walign,
252 unsigned int *h, unsigned int hmin, 314 unsigned int *height, unsigned int hmin,
253 unsigned int hmax, unsigned int halign, 315 unsigned int hmax, unsigned int halign,
254 unsigned int salign); 316 unsigned int salign);
255 317
256struct v4l2_discrete_probe { 318/**
257 const struct v4l2_frmsize_discrete *sizes; 319 * v4l2_find_nearest_format - find the nearest format size among a discrete
258 int num_sizes; 320 * set of resolutions.
259}; 321 *
260 322 * @sizes: array of &struct v4l2_frmsize_discrete image sizes.
261const struct v4l2_frmsize_discrete *v4l2_find_nearest_format( 323 * @num_sizes: length of @sizes array.
262 const struct v4l2_discrete_probe *probe, 324 * @width: desired width.
263 s32 width, s32 height); 325 * @height: desired height.
326 *
327 * Finds the closest resolution to minimize the width and height differences
328 * between what requested and the supported resolutions.
329 */
330const struct v4l2_frmsize_discrete *
331v4l2_find_nearest_format(const struct v4l2_frmsize_discrete *sizes,
332 const size_t num_sizes,
333 s32 width, s32 height);
264 334
335/**
336 * v4l2_get_timestamp - helper routine to get a timestamp to be used when
337 * filling streaming metadata. Internally, it uses ktime_get_ts(),
338 * which is the recommended way to get it.
339 *
340 * @tv: pointer to &struct timeval to be filled.
341 */
265void v4l2_get_timestamp(struct timeval *tv); 342void v4l2_get_timestamp(struct timeval *tv);
266 343
267#endif /* V4L2_COMMON_H_ */ 344#endif /* V4L2_COMMON_H_ */
diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
index a9ced6bbee55..05ebb9ef9e73 100644
--- a/include/media/v4l2-ctrls.h
+++ b/include/media/v4l2-ctrls.h
@@ -166,8 +166,15 @@ typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl *ctrl, void *priv);
166 * empty strings ("") correspond to non-existing menu items (this 166 * empty strings ("") correspond to non-existing menu items (this
167 * is in addition to the menu_skip_mask above). The last entry 167 * is in addition to the menu_skip_mask above). The last entry
168 * must be NULL. 168 * must be NULL.
169 * Used only if the @type is %V4L2_CTRL_TYPE_MENU.
170 * @qmenu_int: A 64-bit integer array for with integer menu items.
171 * The size of array must be equal to the menu size, e. g.:
172 * :math:`ceil(\frac{maximum - minimum}{step}) + 1`.
173 * Used only if the @type is %V4L2_CTRL_TYPE_INTEGER_MENU.
169 * @flags: The control's flags. 174 * @flags: The control's flags.
170 * @cur: The control's current value. 175 * @cur: Structure to store the current value.
176 * @cur.val: The control's current value, if the @type is represented via
177 * a u32 integer (see &enum v4l2_ctrl_type).
171 * @val: The control's new s32 value. 178 * @val: The control's new s32 value.
172 * @priv: The control's private pointer. For use by the driver. It is 179 * @priv: The control's private pointer. For use by the driver. It is
173 * untouched by the control framework. Note that this pointer is 180 * untouched by the control framework. Note that this pointer is
@@ -1139,7 +1146,7 @@ int v4l2_s_ext_ctrls(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl,
1139 1146
1140/** 1147/**
1141 * v4l2_ctrl_subdev_subscribe_event - Helper function to implement 1148 * v4l2_ctrl_subdev_subscribe_event - Helper function to implement
1142 * as a &struct v4l2_subdev_core_ops subscribe_event function 1149 * as a &struct v4l2_subdev_core_ops subscribe_event function
1143 * that just subscribes control events. 1150 * that just subscribes control events.
1144 * 1151 *
1145 * @sd: pointer to &struct v4l2_subdev 1152 * @sd: pointer to &struct v4l2_subdev
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
index fa99f6f66712..53f32022fabe 100644
--- a/include/media/v4l2-dev.h
+++ b/include/media/v4l2-dev.h
@@ -21,31 +21,63 @@
21 21
22#define VIDEO_MAJOR 81 22#define VIDEO_MAJOR 81
23 23
24#define VFL_TYPE_GRABBER 0 24/**
25#define VFL_TYPE_VBI 1 25 * enum vfl_devnode_type - type of V4L2 device node
26#define VFL_TYPE_RADIO 2 26 *
27#define VFL_TYPE_SUBDEV 3 27 * @VFL_TYPE_GRABBER: for video input/output devices
28#define VFL_TYPE_SDR 4 28 * @VFL_TYPE_VBI: for vertical blank data (i.e. closed captions, teletext)
29#define VFL_TYPE_TOUCH 5 29 * @VFL_TYPE_RADIO: for radio tuners
30#define VFL_TYPE_MAX 6 30 * @VFL_TYPE_SUBDEV: for V4L2 subdevices
31 31 * @VFL_TYPE_SDR: for Software Defined Radio tuners
32/* Is this a receiver, transmitter or mem-to-mem? */ 32 * @VFL_TYPE_TOUCH: for touch sensors
33/* Ignored for VFL_TYPE_SUBDEV. */ 33 */
34#define VFL_DIR_RX 0 34enum vfl_devnode_type {
35#define VFL_DIR_TX 1 35 VFL_TYPE_GRABBER = 0,
36#define VFL_DIR_M2M 2 36 VFL_TYPE_VBI = 1,
37 VFL_TYPE_RADIO = 2,
38 VFL_TYPE_SUBDEV = 3,
39 VFL_TYPE_SDR = 4,
40 VFL_TYPE_TOUCH = 5,
41};
42#define VFL_TYPE_MAX VFL_TYPE_TOUCH
43
44/**
45 * enum vfl_direction - Identifies if a &struct video_device corresponds
46 * to a receiver, a transmitter or a mem-to-mem device.
47 *
48 * @VFL_DIR_RX: device is a receiver.
49 * @VFL_DIR_TX: device is a transmitter.
50 * @VFL_DIR_M2M: device is a memory to memory device.
51 *
52 * Note: Ignored if &enum vfl_devnode_type is %VFL_TYPE_SUBDEV.
53 */
54enum vfl_devnode_direction {
55 VFL_DIR_RX,
56 VFL_DIR_TX,
57 VFL_DIR_M2M,
58};
37 59
38struct v4l2_ioctl_callbacks; 60struct v4l2_ioctl_callbacks;
39struct video_device; 61struct video_device;
40struct v4l2_device; 62struct v4l2_device;
41struct v4l2_ctrl_handler; 63struct v4l2_ctrl_handler;
42 64
43/* Flag to mark the video_device struct as registered. 65/**
44 Drivers can clear this flag if they want to block all future 66 * enum v4l2_video_device_flags - Flags used by &struct video_device
45 device access. It is cleared by video_unregister_device. */ 67 *
46#define V4L2_FL_REGISTERED (0) 68 * @V4L2_FL_REGISTERED:
47/* file->private_data points to struct v4l2_fh */ 69 * indicates that a &struct video_device is registered.
48#define V4L2_FL_USES_V4L2_FH (1) 70 * Drivers can clear this flag if they want to block all future
71 * device access. It is cleared by video_unregister_device.
72 * @V4L2_FL_USES_V4L2_FH:
73 * indicates that file->private_data points to &struct v4l2_fh.
74 * This flag is set by the core when v4l2_fh_init() is called.
75 * All new drivers should use it.
76 */
77enum v4l2_video_device_flags {
78 V4L2_FL_REGISTERED = 0,
79 V4L2_FL_USES_V4L2_FH = 1,
80};
49 81
50/* Priority helper functions */ 82/* Priority helper functions */
51 83
@@ -166,7 +198,7 @@ struct v4l2_file_operations {
166 198
167/* 199/*
168 * Newer version of video_device, handled by videodev2.c 200 * Newer version of video_device, handled by videodev2.c
169 * This version moves redundant code from video device code to 201 * This version moves redundant code from video device code to
170 * the common handler 202 * the common handler
171 */ 203 */
172 204
@@ -189,11 +221,12 @@ struct v4l2_file_operations {
189 * @prio: pointer to &struct v4l2_prio_state with device's Priority state. 221 * @prio: pointer to &struct v4l2_prio_state with device's Priority state.
190 * If NULL, then v4l2_dev->prio will be used. 222 * If NULL, then v4l2_dev->prio will be used.
191 * @name: video device name 223 * @name: video device name
192 * @vfl_type: V4L device type 224 * @vfl_type: V4L device type, as defined by &enum vfl_devnode_type
193 * @vfl_dir: V4L receiver, transmitter or m2m 225 * @vfl_dir: V4L receiver, transmitter or m2m
194 * @minor: device node 'minor'. It is set to -1 if the registration failed 226 * @minor: device node 'minor'. It is set to -1 if the registration failed
195 * @num: number of the video device node 227 * @num: number of the video device node
196 * @flags: video device flags. Use bitops to set/clear/test flags 228 * @flags: video device flags. Use bitops to set/clear/test flags.
229 * Contains a set of &enum v4l2_video_device_flags.
197 * @index: attribute to differentiate multiple indices on one physical device 230 * @index: attribute to differentiate multiple indices on one physical device
198 * @fh_lock: Lock for all v4l2_fhs 231 * @fh_lock: Lock for all v4l2_fhs
199 * @fh_list: List of &struct v4l2_fh 232 * @fh_list: List of &struct v4l2_fh
@@ -237,8 +270,8 @@ struct video_device
237 270
238 /* device info */ 271 /* device info */
239 char name[32]; 272 char name[32];
240 int vfl_type; 273 enum vfl_devnode_type vfl_type;
241 int vfl_dir; 274 enum vfl_devnode_direction vfl_dir;
242 int minor; 275 int minor;
243 u16 num; 276 u16 num;
244 unsigned long flags; 277 unsigned long flags;
@@ -261,18 +294,30 @@ struct video_device
261 struct mutex *lock; 294 struct mutex *lock;
262}; 295};
263 296
264#define media_entity_to_video_device(__e) \ 297/**
265 container_of(__e, struct video_device, entity) 298 * media_entity_to_video_device - Returns a &struct video_device from
266/* dev to video-device */ 299 * the &struct media_entity embedded on it.
300 *
301 * @entity: pointer to &struct media_entity
302 */
303#define media_entity_to_video_device(entity) \
304 container_of(entity, struct video_device, entity)
305
306/**
307 * to_video_device - Returns a &struct video_device from the
308 * &struct device embedded on it.
309 *
310 * @cd: pointer to &struct device
311 */
267#define to_video_device(cd) container_of(cd, struct video_device, dev) 312#define to_video_device(cd) container_of(cd, struct video_device, dev)
268 313
269/** 314/**
270 * __video_register_device - register video4linux devices 315 * __video_register_device - register video4linux devices
271 * 316 *
272 * @vdev: struct video_device to register 317 * @vdev: struct video_device to register
273 * @type: type of device to register 318 * @type: type of device to register, as defined by &enum vfl_devnode_type
274 * @nr: which device node number is desired: 319 * @nr: which device node number is desired:
275 * (0 == /dev/video0, 1 == /dev/video1, ..., -1 == first free) 320 * (0 == /dev/video0, 1 == /dev/video1, ..., -1 == first free)
276 * @warn_if_nr_in_use: warn if the desired device node number 321 * @warn_if_nr_in_use: warn if the desired device node number
277 * was already in use and another number was chosen instead. 322 * was already in use and another number was chosen instead.
278 * @owner: module that owns the video device node 323 * @owner: module that owns the video device node
@@ -289,43 +334,37 @@ struct video_device
289 * 334 *
290 * Returns 0 on success. 335 * Returns 0 on success.
291 * 336 *
292 * Valid values for @type are:
293 *
294 * - %VFL_TYPE_GRABBER - A frame grabber
295 * - %VFL_TYPE_VBI - Vertical blank data (undecoded)
296 * - %VFL_TYPE_RADIO - A radio card
297 * - %VFL_TYPE_SUBDEV - A subdevice
298 * - %VFL_TYPE_SDR - Software Defined Radio
299 * - %VFL_TYPE_TOUCH - A touch sensor
300 *
301 * .. note:: 337 * .. note::
302 * 338 *
303 * This function is meant to be used only inside the V4L2 core. 339 * This function is meant to be used only inside the V4L2 core.
304 * Drivers should use video_register_device() or 340 * Drivers should use video_register_device() or
305 * video_register_device_no_warn(). 341 * video_register_device_no_warn().
306 */ 342 */
307int __must_check __video_register_device(struct video_device *vdev, int type, 343int __must_check __video_register_device(struct video_device *vdev,
308 int nr, int warn_if_nr_in_use, struct module *owner); 344 enum vfl_devnode_type type,
345 int nr, int warn_if_nr_in_use,
346 struct module *owner);
309 347
310/** 348/**
311 * video_register_device - register video4linux devices 349 * video_register_device - register video4linux devices
312 * 350 *
313 * @vdev: struct video_device to register 351 * @vdev: struct video_device to register
314 * @type: type of device to register 352 * @type: type of device to register, as defined by &enum vfl_devnode_type
315 * @nr: which device node number is desired: 353 * @nr: which device node number is desired:
316 * (0 == /dev/video0, 1 == /dev/video1, ..., -1 == first free) 354 * (0 == /dev/video0, 1 == /dev/video1, ..., -1 == first free)
317 * 355 *
318 * Internally, it calls __video_register_device(). Please see its 356 * Internally, it calls __video_register_device(). Please see its
319 * documentation for more details. 357 * documentation for more details.
320 * 358 *
321 * .. note:: 359 * .. note::
322 * if video_register_device fails, the release() callback of 360 * if video_register_device fails, the release() callback of
323 * &struct video_device structure is *not* called, so the caller 361 * &struct video_device structure is *not* called, so the caller
324 * is responsible for freeing any data. Usually that means that 362 * is responsible for freeing any data. Usually that means that
325 * you video_device_release() should be called on failure. 363 * you video_device_release() should be called on failure.
326 */ 364 */
327static inline int __must_check video_register_device(struct video_device *vdev, 365static inline int __must_check video_register_device(struct video_device *vdev,
328 int type, int nr) 366 enum vfl_devnode_type type,
367 int nr)
329{ 368{
330 return __video_register_device(vdev, type, nr, 1, vdev->fops->owner); 369 return __video_register_device(vdev, type, nr, 1, vdev->fops->owner);
331} 370}
@@ -334,9 +373,9 @@ static inline int __must_check video_register_device(struct video_device *vdev,
334 * video_register_device_no_warn - register video4linux devices 373 * video_register_device_no_warn - register video4linux devices
335 * 374 *
336 * @vdev: struct video_device to register 375 * @vdev: struct video_device to register
337 * @type: type of device to register 376 * @type: type of device to register, as defined by &enum vfl_devnode_type
338 * @nr: which device node number is desired: 377 * @nr: which device node number is desired:
339 * (0 == /dev/video0, 1 == /dev/video1, ..., -1 == first free) 378 * (0 == /dev/video0, 1 == /dev/video1, ..., -1 == first free)
340 * 379 *
341 * This function is identical to video_register_device() except that no 380 * This function is identical to video_register_device() except that no
342 * warning is issued if the desired device node number was already in use. 381 * warning is issued if the desired device node number was already in use.
@@ -345,13 +384,14 @@ static inline int __must_check video_register_device(struct video_device *vdev,
345 * documentation for more details. 384 * documentation for more details.
346 * 385 *
347 * .. note:: 386 * .. note::
348 * if video_register_device fails, the release() callback of 387 * if video_register_device fails, the release() callback of
349 * &struct video_device structure is *not* called, so the caller 388 * &struct video_device structure is *not* called, so the caller
350 * is responsible for freeing any data. Usually that means that 389 * is responsible for freeing any data. Usually that means that
351 * you video_device_release() should be called on failure. 390 * you video_device_release() should be called on failure.
352 */ 391 */
353static inline int __must_check video_register_device_no_warn( 392static inline int __must_check
354 struct video_device *vdev, int type, int nr) 393video_register_device_no_warn(struct video_device *vdev,
394 enum vfl_devnode_type type, int nr)
355{ 395{
356 return __video_register_device(vdev, type, nr, 0, vdev->fops->owner); 396 return __video_register_device(vdev, type, nr, 0, vdev->fops->owner);
357} 397}
@@ -383,7 +423,7 @@ void video_device_release(struct video_device *vdev);
383 423
384/** 424/**
385 * video_device_release_empty - helper function to implement the 425 * video_device_release_empty - helper function to implement the
386 * video_device->release\(\) callback. 426 * video_device->release\(\) callback.
387 * 427 *
388 * @vdev: pointer to &struct video_device 428 * @vdev: pointer to &struct video_device
389 * 429 *
diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
index 8ffa94009d1a..0c9e4da55499 100644
--- a/include/media/v4l2-device.h
+++ b/include/media/v4l2-device.h
@@ -38,7 +38,7 @@ struct v4l2_ctrl_handler;
38 * @lock: lock this struct; can be used by the driver as well 38 * @lock: lock this struct; can be used by the driver as well
39 * if this struct is embedded into a larger struct. 39 * if this struct is embedded into a larger struct.
40 * @name: unique device name, by default the driver name + bus ID 40 * @name: unique device name, by default the driver name + bus ID
41 * @notify: notify callback called by some sub-devices. 41 * @notify: notify operation called by some sub-devices.
42 * @ctrl_handler: The control handler. May be %NULL. 42 * @ctrl_handler: The control handler. May be %NULL.
43 * @prio: Device's priority state 43 * @prio: Device's priority state
44 * @ref: Keep track of the references to this struct. 44 * @ref: Keep track of the references to this struct.
@@ -56,7 +56,6 @@ struct v4l2_ctrl_handler;
56 * #) @dev->driver_data points to this struct. 56 * #) @dev->driver_data points to this struct.
57 * #) @dev might be %NULL if there is no parent device 57 * #) @dev might be %NULL if there is no parent device
58 */ 58 */
59
60struct v4l2_device { 59struct v4l2_device {
61 struct device *dev; 60 struct device *dev;
62#if defined(CONFIG_MEDIA_CONTROLLER) 61#if defined(CONFIG_MEDIA_CONTROLLER)
@@ -166,7 +165,7 @@ void v4l2_device_unregister(struct v4l2_device *v4l2_dev);
166 * v4l2_device_register_subdev - Registers a subdev with a v4l2 device. 165 * v4l2_device_register_subdev - Registers a subdev with a v4l2 device.
167 * 166 *
168 * @v4l2_dev: pointer to struct &v4l2_device 167 * @v4l2_dev: pointer to struct &v4l2_device
169 * @sd: pointer to struct &v4l2_subdev 168 * @sd: pointer to &struct v4l2_subdev
170 * 169 *
171 * While registered, the subdev module is marked as in-use. 170 * While registered, the subdev module is marked as in-use.
172 * 171 *
@@ -179,7 +178,7 @@ int __must_check v4l2_device_register_subdev(struct v4l2_device *v4l2_dev,
179/** 178/**
180 * v4l2_device_unregister_subdev - Unregisters a subdev with a v4l2 device. 179 * v4l2_device_unregister_subdev - Unregisters a subdev with a v4l2 device.
181 * 180 *
182 * @sd: pointer to struct &v4l2_subdev 181 * @sd: pointer to &struct v4l2_subdev
183 * 182 *
184 * .. note :: 183 * .. note ::
185 * 184 *
@@ -201,7 +200,7 @@ v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev);
201/** 200/**
202 * v4l2_subdev_notify - Sends a notification to v4l2_device. 201 * v4l2_subdev_notify - Sends a notification to v4l2_device.
203 * 202 *
204 * @sd: pointer to struct &v4l2_subdev 203 * @sd: pointer to &struct v4l2_subdev
205 * @notification: type of notification. Please notice that the notification 204 * @notification: type of notification. Please notice that the notification
206 * type is driver-specific. 205 * type is driver-specific.
207 * @arg: arguments for the notification. Those are specific to each 206 * @arg: arguments for the notification. Those are specific to each
@@ -214,13 +213,43 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd,
214 sd->v4l2_dev->notify(sd, notification, arg); 213 sd->v4l2_dev->notify(sd, notification, arg);
215} 214}
216 215
217/* Iterate over all subdevs. */ 216/* Helper macros to iterate over all subdevs. */
217
218/**
219 * v4l2_device_for_each_subdev - Helper macro that interates over all
220 * sub-devices of a given &v4l2_device.
221 *
222 * @sd: pointer that will be filled by the macro with all
223 * &struct v4l2_subdev pointer used as an iterator by the loop.
224 * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over.
225 *
226 * This macro iterates over all sub-devices owned by the @v4l2_dev device.
227 * It acts as a for loop iterator and executes the next statement with
228 * the @sd variable pointing to each sub-device in turn.
229 */
218#define v4l2_device_for_each_subdev(sd, v4l2_dev) \ 230#define v4l2_device_for_each_subdev(sd, v4l2_dev) \
219 list_for_each_entry(sd, &(v4l2_dev)->subdevs, list) 231 list_for_each_entry(sd, &(v4l2_dev)->subdevs, list)
220 232
221/* Call the specified callback for all subdevs matching the condition. 233/**
222 Ignore any errors. Note that you cannot add or delete a subdev 234 * __v4l2_device_call_subdevs_p - Calls the specified operation for
223 while walking the subdevs list. */ 235 * all subdevs matching the condition.
236 *
237 * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over.
238 * @sd: pointer that will be filled by the macro with all
239 * &struct v4l2_subdev pointer used as an iterator by the loop.
240 * @cond: condition to be match
241 * @o: name of the element at &struct v4l2_subdev_ops that contains @f.
242 * Each element there groups a set of operations functions.
243 * @f: operation function that will be called if @cond matches.
244 * The operation functions are defined in groups, according to
245 * each element at &struct v4l2_subdev_ops.
246 * @args...: arguments for @f.
247 *
248 * Ignore any errors.
249 *
250 * Note: subdevs cannot be added or deleted while walking
251 * the subdevs list.
252 */
224#define __v4l2_device_call_subdevs_p(v4l2_dev, sd, cond, o, f, args...) \ 253#define __v4l2_device_call_subdevs_p(v4l2_dev, sd, cond, o, f, args...) \
225 do { \ 254 do { \
226 list_for_each_entry((sd), &(v4l2_dev)->subdevs, list) \ 255 list_for_each_entry((sd), &(v4l2_dev)->subdevs, list) \
@@ -228,6 +257,24 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd,
228 (sd)->ops->o->f((sd) , ##args); \ 257 (sd)->ops->o->f((sd) , ##args); \
229 } while (0) 258 } while (0)
230 259
260/**
261 * __v4l2_device_call_subdevs - Calls the specified operation for
262 * all subdevs matching the condition.
263 *
264 * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over.
265 * @cond: condition to be match
266 * @o: name of the element at &struct v4l2_subdev_ops that contains @f.
267 * Each element there groups a set of operations functions.
268 * @f: operation function that will be called if @cond matches.
269 * The operation functions are defined in groups, according to
270 * each element at &struct v4l2_subdev_ops.
271 * @args...: arguments for @f.
272 *
273 * Ignore any errors.
274 *
275 * Note: subdevs cannot be added or deleted while walking
276 * the subdevs list.
277 */
231#define __v4l2_device_call_subdevs(v4l2_dev, cond, o, f, args...) \ 278#define __v4l2_device_call_subdevs(v4l2_dev, cond, o, f, args...) \
232 do { \ 279 do { \
233 struct v4l2_subdev *__sd; \ 280 struct v4l2_subdev *__sd; \
@@ -236,10 +283,30 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd,
236 f , ##args); \ 283 f , ##args); \
237 } while (0) 284 } while (0)
238 285
239/* Call the specified callback for all subdevs matching the condition. 286/**
240 If the callback returns an error other than 0 or -ENOIOCTLCMD, then 287 * __v4l2_device_call_subdevs_until_err_p - Calls the specified operation for
241 return with that error code. Note that you cannot add or delete a 288 * all subdevs matching the condition.
242 subdev while walking the subdevs list. */ 289 *
290 * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over.
291 * @sd: pointer that will be filled by the macro with all
292 * &struct v4l2_subdev sub-devices associated with @v4l2_dev.
293 * @cond: condition to be match
294 * @o: name of the element at &struct v4l2_subdev_ops that contains @f.
295 * Each element there groups a set of operations functions.
296 * @f: operation function that will be called if @cond matches.
297 * The operation functions are defined in groups, according to
298 * each element at &struct v4l2_subdev_ops.
299 * @args...: arguments for @f.
300 *
301 * Return:
302 *
303 * If the operation returns an error other than 0 or ``-ENOIOCTLCMD``
304 * for any subdevice, then abort and return with that error code, zero
305 * otherwise.
306 *
307 * Note: subdevs cannot be added or deleted while walking
308 * the subdevs list.
309 */
243#define __v4l2_device_call_subdevs_until_err_p(v4l2_dev, sd, cond, o, f, args...) \ 310#define __v4l2_device_call_subdevs_until_err_p(v4l2_dev, sd, cond, o, f, args...) \
244({ \ 311({ \
245 long __err = 0; \ 312 long __err = 0; \
@@ -253,6 +320,28 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd,
253 (__err == -ENOIOCTLCMD) ? 0 : __err; \ 320 (__err == -ENOIOCTLCMD) ? 0 : __err; \
254}) 321})
255 322
323/**
324 * __v4l2_device_call_subdevs_until_err - Calls the specified operation for
325 * all subdevs matching the condition.
326 *
327 * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over.
328 * @cond: condition to be match
329 * @o: name of the element at &struct v4l2_subdev_ops that contains @f.
330 * Each element there groups a set of operations functions.
331 * @f: operation function that will be called if @cond matches.
332 * The operation functions are defined in groups, according to
333 * each element at &struct v4l2_subdev_ops.
334 * @args...: arguments for @f.
335 *
336 * Return:
337 *
338 * If the operation returns an error other than 0 or ``-ENOIOCTLCMD``
339 * for any subdevice, then abort and return with that error code,
340 * zero otherwise.
341 *
342 * Note: subdevs cannot be added or deleted while walking
343 * the subdevs list.
344 */
256#define __v4l2_device_call_subdevs_until_err(v4l2_dev, cond, o, f, args...) \ 345#define __v4l2_device_call_subdevs_until_err(v4l2_dev, cond, o, f, args...) \
257({ \ 346({ \
258 struct v4l2_subdev *__sd; \ 347 struct v4l2_subdev *__sd; \
@@ -260,9 +349,26 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd,
260 f , ##args); \ 349 f , ##args); \
261}) 350})
262 351
263/* Call the specified callback for all subdevs matching grp_id (if 0, then 352/**
264 match them all). Ignore any errors. Note that you cannot add or delete 353 * v4l2_device_call_all - Calls the specified operation for
265 a subdev while walking the subdevs list. */ 354 * all subdevs matching the &v4l2_subdev.grp_id, as assigned
355 * by the bridge driver.
356 *
357 * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over.
358 * @grpid: &struct v4l2_subdev->grp_id group ID to match.
359 * Use 0 to match them all.
360 * @o: name of the element at &struct v4l2_subdev_ops that contains @f.
361 * Each element there groups a set of operations functions.
362 * @f: operation function that will be called if @cond matches.
363 * The operation functions are defined in groups, according to
364 * each element at &struct v4l2_subdev_ops.
365 * @args...: arguments for @f.
366 *
367 * Ignore any errors.
368 *
369 * Note: subdevs cannot be added or deleted while walking
370 * the subdevs list.
371 */
266#define v4l2_device_call_all(v4l2_dev, grpid, o, f, args...) \ 372#define v4l2_device_call_all(v4l2_dev, grpid, o, f, args...) \
267 do { \ 373 do { \
268 struct v4l2_subdev *__sd; \ 374 struct v4l2_subdev *__sd; \
@@ -272,10 +378,30 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd,
272 ##args); \ 378 ##args); \
273 } while (0) 379 } while (0)
274 380
275/* Call the specified callback for all subdevs matching grp_id (if 0, then 381/**
276 match them all). If the callback returns an error other than 0 or 382 * v4l2_device_call_until_err - Calls the specified operation for
277 -ENOIOCTLCMD, then return with that error code. Note that you cannot 383 * all subdevs matching the &v4l2_subdev.grp_id, as assigned
278 add or delete a subdev while walking the subdevs list. */ 384 * by the bridge driver, until an error occurs.
385 *
386 * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over.
387 * @grpid: &struct v4l2_subdev->grp_id group ID to match.
388 * Use 0 to match them all.
389 * @o: name of the element at &struct v4l2_subdev_ops that contains @f.
390 * Each element there groups a set of operations functions.
391 * @f: operation function that will be called if @cond matches.
392 * The operation functions are defined in groups, according to
393 * each element at &struct v4l2_subdev_ops.
394 * @args...: arguments for @f.
395 *
396 * Return:
397 *
398 * If the operation returns an error other than 0 or ``-ENOIOCTLCMD``
399 * for any subdevice, then abort and return with that error code,
400 * zero otherwise.
401 *
402 * Note: subdevs cannot be added or deleted while walking
403 * the subdevs list.
404 */
279#define v4l2_device_call_until_err(v4l2_dev, grpid, o, f, args...) \ 405#define v4l2_device_call_until_err(v4l2_dev, grpid, o, f, args...) \
280({ \ 406({ \
281 struct v4l2_subdev *__sd; \ 407 struct v4l2_subdev *__sd; \
@@ -284,10 +410,24 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd,
284 ##args); \ 410 ##args); \
285}) 411})
286 412
287/* 413/**
288 * Call the specified callback for all subdevs where grp_id & grpmsk != 0 414 * v4l2_device_mask_call_all - Calls the specified operation for
289 * (if grpmsk == `0, then match them all). Ignore any errors. Note that you 415 * all subdevices where a group ID matches a specified bitmask.
290 * cannot add or delete a subdev while walking the subdevs list. 416 *
417 * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over.
418 * @grpmsk: bitmask to be checked against &struct v4l2_subdev->grp_id
419 * group ID to be matched. Use 0 to match them all.
420 * @o: name of the element at &struct v4l2_subdev_ops that contains @f.
421 * Each element there groups a set of operations functions.
422 * @f: operation function that will be called if @cond matches.
423 * The operation functions are defined in groups, according to
424 * each element at &struct v4l2_subdev_ops.
425 * @args...: arguments for @f.
426 *
427 * Ignore any errors.
428 *
429 * Note: subdevs cannot be added or deleted while walking
430 * the subdevs list.
291 */ 431 */
292#define v4l2_device_mask_call_all(v4l2_dev, grpmsk, o, f, args...) \ 432#define v4l2_device_mask_call_all(v4l2_dev, grpmsk, o, f, args...) \
293 do { \ 433 do { \
@@ -298,11 +438,28 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd,
298 ##args); \ 438 ##args); \
299 } while (0) 439 } while (0)
300 440
301/* 441/**
302 * Call the specified callback for all subdevs where grp_id & grpmsk != 0 442 * v4l2_device_mask_call_until_err - Calls the specified operation for
303 * (if grpmsk == 0, then match them all). If the callback returns an error 443 * all subdevices where a group ID matches a specified bitmask.
304 * other than 0 or %-ENOIOCTLCMD, then return with that error code. Note that 444 *
305 * you cannot add or delete a subdev while walking the subdevs list. 445 * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over.
446 * @grpmsk: bitmask to be checked against &struct v4l2_subdev->grp_id
447 * group ID to be matched. Use 0 to match them all.
448 * @o: name of the element at &struct v4l2_subdev_ops that contains @f.
449 * Each element there groups a set of operations functions.
450 * @f: operation function that will be called if @cond matches.
451 * The operation functions are defined in groups, according to
452 * each element at &struct v4l2_subdev_ops.
453 * @args...: arguments for @f.
454 *
455 * Return:
456 *
457 * If the operation returns an error other than 0 or ``-ENOIOCTLCMD``
458 * for any subdevice, then abort and return with that error code,
459 * zero otherwise.
460 *
461 * Note: subdevs cannot be added or deleted while walking
462 * the subdevs list.
306 */ 463 */
307#define v4l2_device_mask_call_until_err(v4l2_dev, grpmsk, o, f, args...) \ 464#define v4l2_device_mask_call_until_err(v4l2_dev, grpmsk, o, f, args...) \
308({ \ 465({ \
@@ -312,9 +469,19 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd,
312 ##args); \ 469 ##args); \
313}) 470})
314 471
315/* 472
316 * Does any subdev with matching grpid (or all if grpid == 0) has the given 473/**
317 * op? 474 * v4l2_device_has_op - checks if any subdev with matching grpid has a
475 * given ops.
476 *
477 * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over.
478 * @grpid: &struct v4l2_subdev->grp_id group ID to match.
479 * Use 0 to match them all.
480 * @o: name of the element at &struct v4l2_subdev_ops that contains @f.
481 * Each element there groups a set of operations functions.
482 * @f: operation function that will be called if @cond matches.
483 * The operation functions are defined in groups, according to
484 * each element at &struct v4l2_subdev_ops.
318 */ 485 */
319#define v4l2_device_has_op(v4l2_dev, grpid, o, f) \ 486#define v4l2_device_has_op(v4l2_dev, grpid, o, f) \
320({ \ 487({ \
@@ -331,9 +498,18 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd,
331 __result; \ 498 __result; \
332}) 499})
333 500
334/* 501/**
335 * Does any subdev with matching grpmsk (or all if grpmsk == 0) has the given 502 * v4l2_device_mask_has_op - checks if any subdev with matching group
336 * op? 503 * mask has a given ops.
504 *
505 * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over.
506 * @grpmsk: bitmask to be checked against &struct v4l2_subdev->grp_id
507 * group ID to be matched. Use 0 to match them all.
508 * @o: name of the element at &struct v4l2_subdev_ops that contains @f.
509 * Each element there groups a set of operations functions.
510 * @f: operation function that will be called if @cond matches.
511 * The operation functions are defined in groups, according to
512 * each element at &struct v4l2_subdev_ops.
337 */ 513 */
338#define v4l2_device_mask_has_op(v4l2_dev, grpmsk, o, f) \ 514#define v4l2_device_mask_has_op(v4l2_dev, grpmsk, o, f) \
339({ \ 515({ \
diff --git a/include/media/v4l2-dv-timings.h b/include/media/v4l2-dv-timings.h
index 61a18893e004..ebf00e07a515 100644
--- a/include/media/v4l2-dv-timings.h
+++ b/include/media/v4l2-dv-timings.h
@@ -203,13 +203,15 @@ struct v4l2_fract v4l2_calc_aspect_ratio(u8 hor_landscape, u8 vert_portrait);
203 */ 203 */
204struct v4l2_fract v4l2_dv_timings_aspect_ratio(const struct v4l2_dv_timings *t); 204struct v4l2_fract v4l2_dv_timings_aspect_ratio(const struct v4l2_dv_timings *t);
205 205
206/* 206/**
207 * reduce_fps - check if conditions for reduced fps are true. 207 * can_reduce_fps - check if conditions for reduced fps are true.
208 * bt - v4l2 timing structure 208 * @bt: v4l2 timing structure
209 * For different timings reduced fps is allowed if following conditions 209 *
210 * are met - 210 * For different timings reduced fps is allowed if the following conditions
211 * For CVT timings: if reduced blanking v2 (vsync == 8) is true. 211 * are met:
212 * For CEA861 timings: if V4L2_DV_FL_CAN_REDUCE_FPS flag is true. 212 *
213 * - For CVT timings: if reduced blanking v2 (vsync == 8) is true.
214 * - For CEA861 timings: if %V4L2_DV_FL_CAN_REDUCE_FPS flag is true.
213 */ 215 */
214static inline bool can_reduce_fps(struct v4l2_bt_timings *bt) 216static inline bool can_reduce_fps(struct v4l2_bt_timings *bt)
215{ 217{
diff --git a/include/media/v4l2-event.h b/include/media/v4l2-event.h
index 6741910c3a18..17833e886e11 100644
--- a/include/media/v4l2-event.h
+++ b/include/media/v4l2-event.h
@@ -24,40 +24,6 @@
24#include <linux/videodev2.h> 24#include <linux/videodev2.h>
25#include <linux/wait.h> 25#include <linux/wait.h>
26 26
27/*
28 * Overview:
29 *
30 * Events are subscribed per-filehandle. An event specification consists of a
31 * type and is optionally associated with an object identified through the
32 * 'id' field. So an event is uniquely identified by the (type, id) tuple.
33 *
34 * The v4l2-fh struct has a list of subscribed events. The v4l2_subscribed_event
35 * struct is added to that list, one for every subscribed event.
36 *
37 * Each v4l2_subscribed_event struct ends with an array of v4l2_kevent structs.
38 * This array (ringbuffer, really) is used to store any events raised by the
39 * driver. The v4l2_kevent struct links into the 'available' list of the
40 * v4l2_fh struct so VIDIOC_DQEVENT will know which event to dequeue first.
41 *
42 * Finally, if the event subscription is associated with a particular object
43 * such as a V4L2 control, then that object needs to know about that as well
44 * so that an event can be raised by that object. So the 'node' field can
45 * be used to link the v4l2_subscribed_event struct into a list of that
46 * object.
47 *
48 * So to summarize:
49 *
50 * struct v4l2_fh has two lists: one of the subscribed events, and one of the
51 * pending events.
52 *
53 * struct v4l2_subscribed_event has a ringbuffer of raised (pending) events of
54 * that particular type.
55 *
56 * If struct v4l2_subscribed_event is associated with a specific object, then
57 * that object will have an internal list of struct v4l2_subscribed_event so
58 * it knows who subscribed an event to that object.
59 */
60
61struct v4l2_fh; 27struct v4l2_fh;
62struct v4l2_subdev; 28struct v4l2_subdev;
63struct v4l2_subscribed_event; 29struct v4l2_subscribed_event;
@@ -218,7 +184,7 @@ int v4l2_event_subdev_unsubscribe(struct v4l2_subdev *sd,
218 struct v4l2_event_subscription *sub); 184 struct v4l2_event_subscription *sub);
219/** 185/**
220 * v4l2_src_change_event_subscribe - helper function that calls 186 * v4l2_src_change_event_subscribe - helper function that calls
221 * v4l2_event_subscribe() if the event is %V4L2_EVENT_SOURCE_CHANGE. 187 * v4l2_event_subscribe() if the event is %V4L2_EVENT_SOURCE_CHANGE.
222 * 188 *
223 * @fh: pointer to struct v4l2_fh 189 * @fh: pointer to struct v4l2_fh
224 * @sub: pointer to &struct v4l2_event_subscription 190 * @sub: pointer to &struct v4l2_event_subscription
diff --git a/include/media/v4l2-flash-led-class.h b/include/media/v4l2-flash-led-class.h
index 5c1d50f78e12..0a5e4518ca11 100644
--- a/include/media/v4l2-flash-led-class.h
+++ b/include/media/v4l2-flash-led-class.h
@@ -91,12 +91,24 @@ struct v4l2_flash {
91 struct v4l2_ctrl **ctrls; 91 struct v4l2_ctrl **ctrls;
92}; 92};
93 93
94/**
95 * v4l2_subdev_to_v4l2_flash - Returns a &struct v4l2_flash from the
96 * &struct v4l2_subdev embedded on it.
97 *
98 * @sd: pointer to &struct v4l2_subdev
99 */
94static inline struct v4l2_flash *v4l2_subdev_to_v4l2_flash( 100static inline struct v4l2_flash *v4l2_subdev_to_v4l2_flash(
95 struct v4l2_subdev *sd) 101 struct v4l2_subdev *sd)
96{ 102{
97 return container_of(sd, struct v4l2_flash, sd); 103 return container_of(sd, struct v4l2_flash, sd);
98} 104}
99 105
106/**
107 * v4l2_ctrl_to_v4l2_flash - Returns a &struct v4l2_flash from the
108 * &struct v4l2_ctrl embedded on it.
109 *
110 * @c: pointer to &struct v4l2_ctrl
111 */
100static inline struct v4l2_flash *v4l2_ctrl_to_v4l2_flash(struct v4l2_ctrl *c) 112static inline struct v4l2_flash *v4l2_ctrl_to_v4l2_flash(struct v4l2_ctrl *c)
101{ 113{
102 return container_of(c->handler, struct v4l2_flash, hdl); 114 return container_of(c->handler, struct v4l2_flash, hdl);
diff --git a/include/media/v4l2-fwnode.h b/include/media/v4l2-fwnode.h
index b5b465677d28..c228ec1c77cf 100644
--- a/include/media/v4l2-fwnode.h
+++ b/include/media/v4l2-fwnode.h
@@ -81,7 +81,17 @@ struct v4l2_fwnode_bus_mipi_csi1 {
81 * struct v4l2_fwnode_endpoint - the endpoint data structure 81 * struct v4l2_fwnode_endpoint - the endpoint data structure
82 * @base: fwnode endpoint of the v4l2_fwnode 82 * @base: fwnode endpoint of the v4l2_fwnode
83 * @bus_type: bus type 83 * @bus_type: bus type
84 * @bus: bus configuration data structure 84 * @bus: union with bus configuration data structure
85 * @bus.parallel: embedded &struct v4l2_fwnode_bus_parallel.
86 * Used if the bus is parallel.
87 * @bus.mipi_csi1: embedded &struct v4l2_fwnode_bus_mipi_csi1.
88 * Used if the bus is MIPI Alliance's Camera Serial
89 * Interface version 1 (MIPI CSI1) or Standard
90 * Mobile Imaging Architecture's Compact Camera Port 2
91 * (SMIA CCP2).
92 * @bus.mipi_csi2: embedded &struct v4l2_fwnode_bus_mipi_csi2.
93 * Used if the bus is MIPI Alliance's Camera Serial
94 * Interface version 2 (MIPI CSI2).
85 * @link_frequencies: array of supported link frequencies 95 * @link_frequencies: array of supported link frequencies
86 * @nr_of_link_frequencies: number of elements in link_frequenccies array 96 * @nr_of_link_frequencies: number of elements in link_frequenccies array
87 */ 97 */
diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
index 93f8afcb7a22..4d8626c468bc 100644
--- a/include/media/v4l2-mediabus.h
+++ b/include/media/v4l2-mediabus.h
@@ -12,6 +12,8 @@
12#define V4L2_MEDIABUS_H 12#define V4L2_MEDIABUS_H
13 13
14#include <linux/v4l2-mediabus.h> 14#include <linux/v4l2-mediabus.h>
15#include <linux/bitops.h>
16
15 17
16/* Parallel flags */ 18/* Parallel flags */
17/* 19/*
@@ -20,44 +22,44 @@
20 * horizontal and vertical synchronisation. In "Slave mode" the host is 22 * horizontal and vertical synchronisation. In "Slave mode" the host is
21 * providing these signals to the slave. 23 * providing these signals to the slave.
22 */ 24 */
23#define V4L2_MBUS_MASTER (1 << 0) 25#define V4L2_MBUS_MASTER BIT(0)
24#define V4L2_MBUS_SLAVE (1 << 1) 26#define V4L2_MBUS_SLAVE BIT(1)
25/* 27/*
26 * Signal polarity flags 28 * Signal polarity flags
27 * Note: in BT.656 mode HSYNC, FIELD, and VSYNC are unused 29 * Note: in BT.656 mode HSYNC, FIELD, and VSYNC are unused
28 * V4L2_MBUS_[HV]SYNC* flags should be also used for specifying 30 * V4L2_MBUS_[HV]SYNC* flags should be also used for specifying
29 * configuration of hardware that uses [HV]REF signals 31 * configuration of hardware that uses [HV]REF signals
30 */ 32 */
31#define V4L2_MBUS_HSYNC_ACTIVE_HIGH (1 << 2) 33#define V4L2_MBUS_HSYNC_ACTIVE_HIGH BIT(2)
32#define V4L2_MBUS_HSYNC_ACTIVE_LOW (1 << 3) 34#define V4L2_MBUS_HSYNC_ACTIVE_LOW BIT(3)
33#define V4L2_MBUS_VSYNC_ACTIVE_HIGH (1 << 4) 35#define V4L2_MBUS_VSYNC_ACTIVE_HIGH BIT(4)
34#define V4L2_MBUS_VSYNC_ACTIVE_LOW (1 << 5) 36#define V4L2_MBUS_VSYNC_ACTIVE_LOW BIT(5)
35#define V4L2_MBUS_PCLK_SAMPLE_RISING (1 << 6) 37#define V4L2_MBUS_PCLK_SAMPLE_RISING BIT(6)
36#define V4L2_MBUS_PCLK_SAMPLE_FALLING (1 << 7) 38#define V4L2_MBUS_PCLK_SAMPLE_FALLING BIT(7)
37#define V4L2_MBUS_DATA_ACTIVE_HIGH (1 << 8) 39#define V4L2_MBUS_DATA_ACTIVE_HIGH BIT(8)
38#define V4L2_MBUS_DATA_ACTIVE_LOW (1 << 9) 40#define V4L2_MBUS_DATA_ACTIVE_LOW BIT(9)
39/* FIELD = 0/1 - Field1 (odd)/Field2 (even) */ 41/* FIELD = 0/1 - Field1 (odd)/Field2 (even) */
40#define V4L2_MBUS_FIELD_EVEN_HIGH (1 << 10) 42#define V4L2_MBUS_FIELD_EVEN_HIGH BIT(10)
41/* FIELD = 1/0 - Field1 (odd)/Field2 (even) */ 43/* FIELD = 1/0 - Field1 (odd)/Field2 (even) */
42#define V4L2_MBUS_FIELD_EVEN_LOW (1 << 11) 44#define V4L2_MBUS_FIELD_EVEN_LOW BIT(11)
43/* Active state of Sync-on-green (SoG) signal, 0/1 for LOW/HIGH respectively. */ 45/* Active state of Sync-on-green (SoG) signal, 0/1 for LOW/HIGH respectively. */
44#define V4L2_MBUS_VIDEO_SOG_ACTIVE_HIGH (1 << 12) 46#define V4L2_MBUS_VIDEO_SOG_ACTIVE_HIGH BIT(12)
45#define V4L2_MBUS_VIDEO_SOG_ACTIVE_LOW (1 << 13) 47#define V4L2_MBUS_VIDEO_SOG_ACTIVE_LOW BIT(13)
46 48
47/* Serial flags */ 49/* Serial flags */
48/* How many lanes the client can use */ 50/* How many lanes the client can use */
49#define V4L2_MBUS_CSI2_1_LANE (1 << 0) 51#define V4L2_MBUS_CSI2_1_LANE BIT(0)
50#define V4L2_MBUS_CSI2_2_LANE (1 << 1) 52#define V4L2_MBUS_CSI2_2_LANE BIT(1)
51#define V4L2_MBUS_CSI2_3_LANE (1 << 2) 53#define V4L2_MBUS_CSI2_3_LANE BIT(2)
52#define V4L2_MBUS_CSI2_4_LANE (1 << 3) 54#define V4L2_MBUS_CSI2_4_LANE BIT(3)
53/* On which channels it can send video data */ 55/* On which channels it can send video data */
54#define V4L2_MBUS_CSI2_CHANNEL_0 (1 << 4) 56#define V4L2_MBUS_CSI2_CHANNEL_0 BIT(4)
55#define V4L2_MBUS_CSI2_CHANNEL_1 (1 << 5) 57#define V4L2_MBUS_CSI2_CHANNEL_1 BIT(5)
56#define V4L2_MBUS_CSI2_CHANNEL_2 (1 << 6) 58#define V4L2_MBUS_CSI2_CHANNEL_2 BIT(6)
57#define V4L2_MBUS_CSI2_CHANNEL_3 (1 << 7) 59#define V4L2_MBUS_CSI2_CHANNEL_3 BIT(7)
58/* Does it support only continuous or also non-continuous clock mode */ 60/* Does it support only continuous or also non-continuous clock mode */
59#define V4L2_MBUS_CSI2_CONTINUOUS_CLOCK (1 << 8) 61#define V4L2_MBUS_CSI2_CONTINUOUS_CLOCK BIT(8)
60#define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK (1 << 9) 62#define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK BIT(9)
61 63
62#define V4L2_MBUS_CSI2_LANES (V4L2_MBUS_CSI2_1_LANE | V4L2_MBUS_CSI2_2_LANE | \ 64#define V4L2_MBUS_CSI2_LANES (V4L2_MBUS_CSI2_1_LANE | V4L2_MBUS_CSI2_2_LANE | \
63 V4L2_MBUS_CSI2_3_LANE | V4L2_MBUS_CSI2_4_LANE) 65 V4L2_MBUS_CSI2_3_LANE | V4L2_MBUS_CSI2_4_LANE)
@@ -91,6 +93,13 @@ struct v4l2_mbus_config {
91 unsigned int flags; 93 unsigned int flags;
92}; 94};
93 95
96/**
97 * v4l2_fill_pix_format - Ancillary routine that fills a &struct
98 * v4l2_pix_format fields from a &struct v4l2_mbus_framefmt.
99 *
100 * @pix_fmt: pointer to &struct v4l2_pix_format to be filled
101 * @mbus_fmt: pointer to &struct v4l2_mbus_framefmt to be used as model
102 */
94static inline void v4l2_fill_pix_format(struct v4l2_pix_format *pix_fmt, 103static inline void v4l2_fill_pix_format(struct v4l2_pix_format *pix_fmt,
95 const struct v4l2_mbus_framefmt *mbus_fmt) 104 const struct v4l2_mbus_framefmt *mbus_fmt)
96{ 105{
@@ -103,6 +112,15 @@ static inline void v4l2_fill_pix_format(struct v4l2_pix_format *pix_fmt,
103 pix_fmt->xfer_func = mbus_fmt->xfer_func; 112 pix_fmt->xfer_func = mbus_fmt->xfer_func;
104} 113}
105 114
115/**
116 * v4l2_fill_pix_format - Ancillary routine that fills a &struct
117 * v4l2_mbus_framefmt from a &struct v4l2_pix_format and a
118 * data format code.
119 *
120 * @mbus_fmt: pointer to &struct v4l2_mbus_framefmt to be filled
121 * @pix_fmt: pointer to &struct v4l2_pix_format to be used as model
122 * @code: data format code (from &enum v4l2_mbus_pixelcode)
123 */
106static inline void v4l2_fill_mbus_format(struct v4l2_mbus_framefmt *mbus_fmt, 124static inline void v4l2_fill_mbus_format(struct v4l2_mbus_framefmt *mbus_fmt,
107 const struct v4l2_pix_format *pix_fmt, 125 const struct v4l2_pix_format *pix_fmt,
108 u32 code) 126 u32 code)
@@ -117,6 +135,13 @@ static inline void v4l2_fill_mbus_format(struct v4l2_mbus_framefmt *mbus_fmt,
117 mbus_fmt->code = code; 135 mbus_fmt->code = code;
118} 136}
119 137
138/**
139 * v4l2_fill_pix_format - Ancillary routine that fills a &struct
140 * v4l2_pix_format_mplane fields from a media bus structure.
141 *
142 * @pix_mp_fmt: pointer to &struct v4l2_pix_format_mplane to be filled
143 * @mbus_fmt: pointer to &struct v4l2_mbus_framefmt to be used as model
144 */
120static inline void v4l2_fill_pix_format_mplane( 145static inline void v4l2_fill_pix_format_mplane(
121 struct v4l2_pix_format_mplane *pix_mp_fmt, 146 struct v4l2_pix_format_mplane *pix_mp_fmt,
122 const struct v4l2_mbus_framefmt *mbus_fmt) 147 const struct v4l2_mbus_framefmt *mbus_fmt)
@@ -130,6 +155,13 @@ static inline void v4l2_fill_pix_format_mplane(
130 pix_mp_fmt->xfer_func = mbus_fmt->xfer_func; 155 pix_mp_fmt->xfer_func = mbus_fmt->xfer_func;
131} 156}
132 157
158/**
159 * v4l2_fill_pix_format - Ancillary routine that fills a &struct
160 * v4l2_mbus_framefmt from a &struct v4l2_pix_format_mplane.
161 *
162 * @mbus_fmt: pointer to &struct v4l2_mbus_framefmt to be filled
163 * @pix_mp_fmt: pointer to &struct v4l2_pix_format_mplane to be used as model
164 */
133static inline void v4l2_fill_mbus_format_mplane( 165static inline void v4l2_fill_mbus_format_mplane(
134 struct v4l2_mbus_framefmt *mbus_fmt, 166 struct v4l2_mbus_framefmt *mbus_fmt,
135 const struct v4l2_pix_format_mplane *pix_mp_fmt) 167 const struct v4l2_pix_format_mplane *pix_mp_fmt)
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index ec399c770301..980a86c08fce 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -108,22 +108,31 @@ struct v4l2_decode_vbi_line {
108 * not yet implemented) since ops provide proper type-checking. 108 * not yet implemented) since ops provide proper type-checking.
109 */ 109 */
110 110
111/* Subdevice external IO pin configuration */ 111/**
112#define V4L2_SUBDEV_IO_PIN_DISABLE (1 << 0) /* ENABLE assumed */ 112 * enum v4l2_subdev_io_pin_bits - Subdevice external IO pin configuration
113#define V4L2_SUBDEV_IO_PIN_OUTPUT (1 << 1) 113 * bits
114#define V4L2_SUBDEV_IO_PIN_INPUT (1 << 2) 114 *
115#define V4L2_SUBDEV_IO_PIN_SET_VALUE (1 << 3) /* Set output value */ 115 * @V4L2_SUBDEV_IO_PIN_DISABLE: disables a pin config. ENABLE assumed.
116#define V4L2_SUBDEV_IO_PIN_ACTIVE_LOW (1 << 4) /* ACTIVE HIGH assumed */ 116 * @V4L2_SUBDEV_IO_PIN_OUTPUT: set it if pin is an output.
117 * @V4L2_SUBDEV_IO_PIN_INPUT: set it if pin is an input.
118 * @V4L2_SUBDEV_IO_PIN_SET_VALUE: to set the output value via
119 * &struct v4l2_subdev_io_pin_config->value.
120 * @V4L2_SUBDEV_IO_PIN_ACTIVE_LOW: pin active is bit 0.
121 * Otherwise, ACTIVE HIGH is assumed.
122 */
123enum v4l2_subdev_io_pin_bits {
124 V4L2_SUBDEV_IO_PIN_DISABLE = 0,
125 V4L2_SUBDEV_IO_PIN_OUTPUT = 1,
126 V4L2_SUBDEV_IO_PIN_INPUT = 2,
127 V4L2_SUBDEV_IO_PIN_SET_VALUE = 3,
128 V4L2_SUBDEV_IO_PIN_ACTIVE_LOW = 4,
129};
117 130
118/** 131/**
119 * struct v4l2_subdev_io_pin_config - Subdevice external IO pin configuration 132 * struct v4l2_subdev_io_pin_config - Subdevice external IO pin configuration
120 * 133 *
121 * @flags: bitmask with flags for this pin's config: 134 * @flags: bitmask with flags for this pin's config, whose bits are defined by
122 * %V4L2_SUBDEV_IO_PIN_DISABLE - disables a pin config, 135 * &enum v4l2_subdev_io_pin_bits.
123 * %V4L2_SUBDEV_IO_PIN_OUTPUT - if pin is an output,
124 * %V4L2_SUBDEV_IO_PIN_INPUT - if pin is an input,
125 * %V4L2_SUBDEV_IO_PIN_SET_VALUE - to set the output value via @value
126 * and %V4L2_SUBDEV_IO_PIN_ACTIVE_LOW - if active is 0.
127 * @pin: Chip external IO pin to configure 136 * @pin: Chip external IO pin to configure
128 * @function: Internal signal pad/function to route to IO pin 137 * @function: Internal signal pad/function to route to IO pin
129 * @value: Initial value for pin - e.g. GPIO output value 138 * @value: Initial value for pin - e.g. GPIO output value
@@ -140,7 +149,7 @@ struct v4l2_subdev_io_pin_config {
140/** 149/**
141 * struct v4l2_subdev_core_ops - Define core ops callbacks for subdevs 150 * struct v4l2_subdev_core_ops - Define core ops callbacks for subdevs
142 * 151 *
143 * @log_status: callback for %VIDIOC_LOG_STATUS ioctl handler code. 152 * @log_status: callback for VIDIOC_LOG_STATUS() ioctl handler code.
144 * 153 *
145 * @s_io_pin_config: configure one or more chip I/O pins for chips that 154 * @s_io_pin_config: configure one or more chip I/O pins for chips that
146 * multiplex different internal signal pads out to IO pins. This function 155 * multiplex different internal signal pads out to IO pins. This function
@@ -168,9 +177,9 @@ struct v4l2_subdev_io_pin_config {
168 * @compat_ioctl32: called when a 32 bits application uses a 64 bits Kernel, 177 * @compat_ioctl32: called when a 32 bits application uses a 64 bits Kernel,
169 * in order to fix data passed from/to userspace. 178 * in order to fix data passed from/to userspace.
170 * 179 *
171 * @g_register: callback for %VIDIOC_G_REGISTER ioctl handler code. 180 * @g_register: callback for VIDIOC_DBG_G_REGISTER() ioctl handler code.
172 * 181 *
173 * @s_register: callback for %VIDIOC_G_REGISTER ioctl handler code. 182 * @s_register: callback for VIDIOC_DBG_S_REGISTER() ioctl handler code.
174 * 183 *
175 * @s_power: puts subdevice in power saving mode (on == 0) or normal operation 184 * @s_power: puts subdevice in power saving mode (on == 0) or normal operation
176 * mode (on == 1). 185 * mode (on == 1).
@@ -215,29 +224,48 @@ struct v4l2_subdev_core_ops {
215 * struct v4l2_subdev_tuner_ops - Callbacks used when v4l device was opened 224 * struct v4l2_subdev_tuner_ops - Callbacks used when v4l device was opened
216 * in radio mode. 225 * in radio mode.
217 * 226 *
218 * @s_radio: callback for %VIDIOC_S_RADIO ioctl handler code. 227 * @s_radio: callback that switches the tuner to radio mode.
228 * drivers should explicitly call it when a tuner ops should
229 * operate on radio mode, before being able to handle it.
230 * Used on devices that have both AM/FM radio receiver and TV.
219 * 231 *
220 * @s_frequency: callback for %VIDIOC_S_FREQUENCY ioctl handler code. 232 * @s_frequency: callback for VIDIOC_S_FREQUENCY() ioctl handler code.
221 * 233 *
222 * @g_frequency: callback for %VIDIOC_G_FREQUENCY ioctl handler code. 234 * @g_frequency: callback for VIDIOC_G_FREQUENCY() ioctl handler code.
223 * freq->type must be filled in. Normally done by video_ioctl2() 235 * freq->type must be filled in. Normally done by video_ioctl2()
224 * or the bridge driver. 236 * or the bridge driver.
225 * 237 *
226 * @enum_freq_bands: callback for %VIDIOC_ENUM_FREQ_BANDS ioctl handler code. 238 * @enum_freq_bands: callback for VIDIOC_ENUM_FREQ_BANDS() ioctl handler code.
227 * 239 *
228 * @g_tuner: callback for %VIDIOC_G_TUNER ioctl handler code. 240 * @g_tuner: callback for VIDIOC_G_TUNER() ioctl handler code.
229 * 241 *
230 * @s_tuner: callback for %VIDIOC_S_TUNER ioctl handler code. @vt->type must be 242 * @s_tuner: callback for VIDIOC_S_TUNER() ioctl handler code. @vt->type must be
231 * filled in. Normally done by video_ioctl2 or the 243 * filled in. Normally done by video_ioctl2 or the
232 * bridge driver. 244 * bridge driver.
233 * 245 *
234 * @g_modulator: callback for %VIDIOC_G_MODULATOR ioctl handler code. 246 * @g_modulator: callback for VIDIOC_G_MODULATOR() ioctl handler code.
235 * 247 *
236 * @s_modulator: callback for %VIDIOC_S_MODULATOR ioctl handler code. 248 * @s_modulator: callback for VIDIOC_S_MODULATOR() ioctl handler code.
237 * 249 *
238 * @s_type_addr: sets tuner type and its I2C addr. 250 * @s_type_addr: sets tuner type and its I2C addr.
239 * 251 *
240 * @s_config: sets tda9887 specific stuff, like port1, port2 and qss 252 * @s_config: sets tda9887 specific stuff, like port1, port2 and qss
253 *
254 * .. note::
255 *
256 * On devices that have both AM/FM and TV, it is up to the driver
257 * to explicitly call s_radio when the tuner should be switched to
258 * radio mode, before handling other &struct v4l2_subdev_tuner_ops
259 * that would require it. An example of such usage is::
260 *
261 * static void s_frequency(void *priv, const struct v4l2_frequency *f)
262 * {
263 * ...
264 * if (f.type == V4L2_TUNER_RADIO)
265 * v4l2_device_call_all(v4l2_dev, 0, tuner, s_radio);
266 * ...
267 * v4l2_device_call_all(v4l2_dev, 0, tuner, s_frequency);
268 * }
241 */ 269 */
242struct v4l2_subdev_tuner_ops { 270struct v4l2_subdev_tuner_ops {
243 int (*s_radio)(struct v4l2_subdev *sd); 271 int (*s_radio)(struct v4l2_subdev *sd);
@@ -285,25 +313,32 @@ struct v4l2_subdev_audio_ops {
285 int (*s_stream)(struct v4l2_subdev *sd, int enable); 313 int (*s_stream)(struct v4l2_subdev *sd, int enable);
286}; 314};
287 315
288/* Indicates the @length field specifies maximum data length. */ 316/**
289#define V4L2_MBUS_FRAME_DESC_FL_LEN_MAX (1U << 0) 317 * enum v4l2_mbus_frame_desc_entry - media bus frame description flags
290/* 318 *
291 * Indicates that the format does not have line offsets, i.e. the 319 * @V4L2_MBUS_FRAME_DESC_FL_LEN_MAX:
292 * receiver should use 1D DMA. 320 * Indicates that &struct v4l2_mbus_frame_desc_entry->length field
321 * specifies maximum data length.
322 * @V4L2_MBUS_FRAME_DESC_FL_BLOB:
323 * Indicates that the format does not have line offsets, i.e.
324 * the receiver should use 1D DMA.
293 */ 325 */
294#define V4L2_MBUS_FRAME_DESC_FL_BLOB (1U << 1) 326enum v4l2_mbus_frame_desc_flags {
327 V4L2_MBUS_FRAME_DESC_FL_LEN_MAX = BIT(0),
328 V4L2_MBUS_FRAME_DESC_FL_BLOB = BIT(1),
329};
295 330
296/** 331/**
297 * struct v4l2_mbus_frame_desc_entry - media bus frame description structure 332 * struct v4l2_mbus_frame_desc_entry - media bus frame description structure
298 * 333 *
299 * @flags: bitmask flags: %V4L2_MBUS_FRAME_DESC_FL_LEN_MAX and 334 * @flags: bitmask flags, as defined by &enum v4l2_mbus_frame_desc_flags.
300 * %V4L2_MBUS_FRAME_DESC_FL_BLOB. 335 * @pixelcode: media bus pixel code, valid if @flags
301 * @pixelcode: media bus pixel code, valid if FRAME_DESC_FL_BLOB is not set 336 * %FRAME_DESC_FL_BLOB is not set.
302 * @length: number of octets per frame, valid if V4L2_MBUS_FRAME_DESC_FL_BLOB 337 * @length: number of octets per frame, valid if @flags
303 * is set 338 * %V4L2_MBUS_FRAME_DESC_FL_LEN_MAX is set.
304 */ 339 */
305struct v4l2_mbus_frame_desc_entry { 340struct v4l2_mbus_frame_desc_entry {
306 u16 flags; 341 enum v4l2_mbus_frame_desc_flags flags;
307 u32 pixelcode; 342 u32 pixelcode;
308 u32 length; 343 u32 length;
309}; 344};
@@ -332,9 +367,9 @@ struct v4l2_mbus_frame_desc {
332 * regarding clock frequency dividers, etc. If not used, then set flags 367 * regarding clock frequency dividers, etc. If not used, then set flags
333 * to 0. If the frequency is not supported, then -EINVAL is returned. 368 * to 0. If the frequency is not supported, then -EINVAL is returned.
334 * 369 *
335 * @g_std: callback for %VIDIOC_G_STD ioctl handler code. 370 * @g_std: callback for VIDIOC_G_STD() ioctl handler code.
336 * 371 *
337 * @s_std: callback for %VIDIOC_S_STD ioctl handler code. 372 * @s_std: callback for VIDIOC_S_STD() ioctl handler code.
338 * 373 *
339 * @s_std_output: set v4l2_std_id for video OUTPUT devices. This is ignored by 374 * @s_std_output: set v4l2_std_id for video OUTPUT devices. This is ignored by
340 * video input devices. 375 * video input devices.
@@ -342,7 +377,7 @@ struct v4l2_mbus_frame_desc {
342 * @g_std_output: get current standard for video OUTPUT devices. This is ignored 377 * @g_std_output: get current standard for video OUTPUT devices. This is ignored
343 * by video input devices. 378 * by video input devices.
344 * 379 *
345 * @querystd: callback for %VIDIOC_QUERYSTD ioctl handler code. 380 * @querystd: callback for VIDIOC_QUERYSTD() ioctl handler code.
346 * 381 *
347 * @g_tvnorms: get &v4l2_std_id with all standards supported by the video 382 * @g_tvnorms: get &v4l2_std_id with all standards supported by the video
348 * CAPTURE device. This is ignored by video output devices. 383 * CAPTURE device. This is ignored by video output devices.
@@ -358,13 +393,15 @@ struct v4l2_mbus_frame_desc {
358 * 393 *
359 * @g_pixelaspect: callback to return the pixelaspect ratio. 394 * @g_pixelaspect: callback to return the pixelaspect ratio.
360 * 395 *
361 * @g_parm: callback for %VIDIOC_G_PARM ioctl handler code. 396 * @g_parm: callback for VIDIOC_G_PARM() ioctl handler code.
362 * 397 *
363 * @s_parm: callback for %VIDIOC_S_PARM ioctl handler code. 398 * @s_parm: callback for VIDIOC_S_PARM() ioctl handler code.
364 * 399 *
365 * @g_frame_interval: callback for %VIDIOC_G_FRAMEINTERVAL ioctl handler code. 400 * @g_frame_interval: callback for VIDIOC_SUBDEV_G_FRAME_INTERVAL()
401 * ioctl handler code.
366 * 402 *
367 * @s_frame_interval: callback for %VIDIOC_S_FRAMEINTERVAL ioctl handler code. 403 * @s_frame_interval: callback for VIDIOC_SUBDEV_S_FRAME_INTERVAL()
404 * ioctl handler code.
368 * 405 *
369 * @s_dv_timings: Set custom dv timings in the sub device. This is used 406 * @s_dv_timings: Set custom dv timings in the sub device. This is used
370 * when sub device is capable of setting detailed timing information 407 * when sub device is capable of setting detailed timing information
@@ -372,7 +409,7 @@ struct v4l2_mbus_frame_desc {
372 * 409 *
373 * @g_dv_timings: Get custom dv timings in the sub device. 410 * @g_dv_timings: Get custom dv timings in the sub device.
374 * 411 *
375 * @query_dv_timings: callback for %VIDIOC_QUERY_DV_TIMINGS ioctl handler code. 412 * @query_dv_timings: callback for VIDIOC_QUERY_DV_TIMINGS() ioctl handler code.
376 * 413 *
377 * @g_mbus_config: get supported mediabus configurations 414 * @g_mbus_config: get supported mediabus configurations
378 * 415 *
@@ -443,7 +480,8 @@ struct v4l2_subdev_video_ops {
443 * member (to determine whether CC data from the first or second field 480 * member (to determine whether CC data from the first or second field
444 * should be obtained). 481 * should be obtained).
445 * 482 *
446 * @g_sliced_vbi_cap: callback for %VIDIOC_SLICED_VBI_CAP ioctl handler code. 483 * @g_sliced_vbi_cap: callback for VIDIOC_G_SLICED_VBI_CAP() ioctl handler
484 * code.
447 * 485 *
448 * @s_raw_fmt: setup the video encoder/decoder for raw VBI. 486 * @s_raw_fmt: setup the video encoder/decoder for raw VBI.
449 * 487 *
@@ -610,30 +648,30 @@ struct v4l2_subdev_pad_config {
610 * struct v4l2_subdev_pad_ops - v4l2-subdev pad level operations 648 * struct v4l2_subdev_pad_ops - v4l2-subdev pad level operations
611 * 649 *
612 * @init_cfg: initialize the pad config to default values 650 * @init_cfg: initialize the pad config to default values
613 * @enum_mbus_code: callback for %VIDIOC_SUBDEV_ENUM_MBUS_CODE ioctl handler 651 * @enum_mbus_code: callback for VIDIOC_SUBDEV_ENUM_MBUS_CODE() ioctl handler
614 * code. 652 * code.
615 * @enum_frame_size: callback for %VIDIOC_SUBDEV_ENUM_FRAME_SIZE ioctl handler 653 * @enum_frame_size: callback for VIDIOC_SUBDEV_ENUM_FRAME_SIZE() ioctl handler
616 * code. 654 * code.
617 * 655 *
618 * @enum_frame_interval: callback for %VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL ioctl 656 * @enum_frame_interval: callback for VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL() ioctl
619 * handler code. 657 * handler code.
620 * 658 *
621 * @get_fmt: callback for %VIDIOC_SUBDEV_G_FMT ioctl handler code. 659 * @get_fmt: callback for VIDIOC_SUBDEV_G_FMT() ioctl handler code.
622 * 660 *
623 * @set_fmt: callback for %VIDIOC_SUBDEV_S_FMT ioctl handler code. 661 * @set_fmt: callback for VIDIOC_SUBDEV_S_FMT() ioctl handler code.
624 * 662 *
625 * @get_selection: callback for %VIDIOC_SUBDEV_G_SELECTION ioctl handler code. 663 * @get_selection: callback for VIDIOC_SUBDEV_G_SELECTION() ioctl handler code.
626 * 664 *
627 * @set_selection: callback for %VIDIOC_SUBDEV_S_SELECTION ioctl handler code. 665 * @set_selection: callback for VIDIOC_SUBDEV_S_SELECTION() ioctl handler code.
628 * 666 *
629 * @get_edid: callback for %VIDIOC_SUBDEV_G_EDID ioctl handler code. 667 * @get_edid: callback for VIDIOC_SUBDEV_G_EDID() ioctl handler code.
630 * 668 *
631 * @set_edid: callback for %VIDIOC_SUBDEV_S_EDID ioctl handler code. 669 * @set_edid: callback for VIDIOC_SUBDEV_S_EDID() ioctl handler code.
632 * 670 *
633 * @dv_timings_cap: callback for %VIDIOC_SUBDEV_DV_TIMINGS_CAP ioctl handler 671 * @dv_timings_cap: callback for VIDIOC_SUBDEV_DV_TIMINGS_CAP() ioctl handler
634 * code. 672 * code.
635 * 673 *
636 * @enum_dv_timings: callback for %VIDIOC_SUBDEV_ENUM_DV_TIMINGS ioctl handler 674 * @enum_dv_timings: callback for VIDIOC_SUBDEV_ENUM_DV_TIMINGS() ioctl handler
637 * code. 675 * code.
638 * 676 *
639 * @link_validate: used by the media controller code to check if the links 677 * @link_validate: used by the media controller code to check if the links
@@ -766,7 +804,7 @@ struct v4l2_subdev_platform_data {
766 * @list: List of sub-devices 804 * @list: List of sub-devices
767 * @owner: The owner is the same as the driver's &struct device owner. 805 * @owner: The owner is the same as the driver's &struct device owner.
768 * @owner_v4l2_dev: true if the &sd->owner matches the owner of @v4l2_dev->dev 806 * @owner_v4l2_dev: true if the &sd->owner matches the owner of @v4l2_dev->dev
769 * ownner. Initialized by v4l2_device_register_subdev(). 807 * owner. Initialized by v4l2_device_register_subdev().
770 * @flags: subdev flags. Can be: 808 * @flags: subdev flags. Can be:
771 * %V4L2_SUBDEV_FL_IS_I2C - Set this flag if this subdev is a i2c device; 809 * %V4L2_SUBDEV_FL_IS_I2C - Set this flag if this subdev is a i2c device;
772 * %V4L2_SUBDEV_FL_IS_SPI - Set this flag if this subdev is a spi device; 810 * %V4L2_SUBDEV_FL_IS_SPI - Set this flag if this subdev is a spi device;
diff --git a/include/media/v4l2-tpg-colors.h b/include/media/v4l2-tpg-colors.h
deleted file mode 100644
index 2a88d1fae0cd..000000000000
--- a/include/media/v4l2-tpg-colors.h
+++ /dev/null
@@ -1,68 +0,0 @@
1/*
2 * v4l2-tpg-colors.h - Color definitions for the test pattern generator
3 *
4 * Copyright 2014 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
5 *
6 * This program is free software; you may redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
11 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
12 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
13 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
14 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
15 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
16 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17 * SOFTWARE.
18 */
19
20#ifndef _V4L2_TPG_COLORS_H_
21#define _V4L2_TPG_COLORS_H_
22
23struct color {
24 unsigned char r, g, b;
25};
26
27struct color16 {
28 int r, g, b;
29};
30
31enum tpg_color {
32 TPG_COLOR_CSC_WHITE,
33 TPG_COLOR_CSC_YELLOW,
34 TPG_COLOR_CSC_CYAN,
35 TPG_COLOR_CSC_GREEN,
36 TPG_COLOR_CSC_MAGENTA,
37 TPG_COLOR_CSC_RED,
38 TPG_COLOR_CSC_BLUE,
39 TPG_COLOR_CSC_BLACK,
40 TPG_COLOR_75_YELLOW,
41 TPG_COLOR_75_CYAN,
42 TPG_COLOR_75_GREEN,
43 TPG_COLOR_75_MAGENTA,
44 TPG_COLOR_75_RED,
45 TPG_COLOR_75_BLUE,
46 TPG_COLOR_100_WHITE,
47 TPG_COLOR_100_YELLOW,
48 TPG_COLOR_100_CYAN,
49 TPG_COLOR_100_GREEN,
50 TPG_COLOR_100_MAGENTA,
51 TPG_COLOR_100_RED,
52 TPG_COLOR_100_BLUE,
53 TPG_COLOR_100_BLACK,
54 TPG_COLOR_TEXTFG,
55 TPG_COLOR_TEXTBG,
56 TPG_COLOR_RANDOM,
57 TPG_COLOR_RAMP,
58 TPG_COLOR_MAX = TPG_COLOR_RAMP + 256
59};
60
61extern const struct color tpg_colors[TPG_COLOR_MAX];
62extern const unsigned short tpg_rec709_to_linear[255 * 16 + 1];
63extern const unsigned short tpg_linear_to_rec709[255 * 16 + 1];
64extern const struct color16 tpg_csc_colors[V4L2_COLORSPACE_DCI_P3 + 1]
65 [V4L2_XFER_FUNC_SMPTE2084 + 1]
66 [TPG_COLOR_CSC_BLACK + 1];
67
68#endif
diff --git a/include/media/videobuf-dvb.h b/include/media/videobuf-dvb.h
index a14ac7711c92..c9c81990a56c 100644
--- a/include/media/videobuf-dvb.h
+++ b/include/media/videobuf-dvb.h
@@ -1,9 +1,9 @@
1/* SPDX-License-Identifier: GPL-2.0 */ 1/* SPDX-License-Identifier: GPL-2.0 */
2#include <dvbdev.h> 2#include <media/dvbdev.h>
3#include <dmxdev.h> 3#include <media/dmxdev.h>
4#include <dvb_demux.h> 4#include <media/dvb_demux.h>
5#include <dvb_net.h> 5#include <media/dvb_net.h>
6#include <dvb_frontend.h> 6#include <media/dvb_frontend.h>
7 7
8#ifndef _VIDEOBUF_DVB_H_ 8#ifndef _VIDEOBUF_DVB_H_
9#define _VIDEOBUF_DVB_H_ 9#define _VIDEOBUF_DVB_H_
diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
index e55efc62a950..aa16c064294f 100644
--- a/include/media/videobuf2-core.h
+++ b/include/media/videobuf2-core.h
@@ -16,6 +16,7 @@
16#include <linux/mutex.h> 16#include <linux/mutex.h>
17#include <linux/poll.h> 17#include <linux/poll.h>
18#include <linux/dma-buf.h> 18#include <linux/dma-buf.h>
19#include <linux/bitops.h>
19 20
20#define VB2_MAX_FRAME (32) 21#define VB2_MAX_FRAME (32)
21#define VB2_MAX_PLANES (8) 22#define VB2_MAX_PLANES (8)
@@ -45,7 +46,7 @@ struct vb2_fileio_data;
45struct vb2_threadio_data; 46struct vb2_threadio_data;
46 47
47/** 48/**
48 * struct vb2_mem_ops - memory handling/memory allocator operations 49 * struct vb2_mem_ops - memory handling/memory allocator operations.
49 * @alloc: allocate video memory and, optionally, allocator private data, 50 * @alloc: allocate video memory and, optionally, allocator private data,
50 * return ERR_PTR() on failure or a pointer to allocator private, 51 * return ERR_PTR() on failure or a pointer to allocator private,
51 * per-buffer data on success; the returned private structure 52 * per-buffer data on success; the returned private structure
@@ -69,7 +70,7 @@ struct vb2_threadio_data;
69 * argument to other ops in this structure. 70 * argument to other ops in this structure.
70 * @put_userptr: inform the allocator that a USERPTR buffer will no longer 71 * @put_userptr: inform the allocator that a USERPTR buffer will no longer
71 * be used. 72 * be used.
72 * @attach_dmabuf: attach a shared struct dma_buf for a hardware operation; 73 * @attach_dmabuf: attach a shared &struct dma_buf for a hardware operation;
73 * used for DMABUF memory types; dev is the alloc device 74 * used for DMABUF memory types; dev is the alloc device
74 * dbuf is the shared dma_buf; returns ERR_PTR() on failure; 75 * dbuf is the shared dma_buf; returns ERR_PTR() on failure;
75 * allocator private per-buffer structure on success; 76 * allocator private per-buffer structure on success;
@@ -145,28 +146,28 @@ struct vb2_mem_ops {
145}; 146};
146 147
147/** 148/**
148 * struct vb2_plane - plane information 149 * struct vb2_plane - plane information.
149 * @mem_priv: private data with this plane 150 * @mem_priv: private data with this plane.
150 * @dbuf: dma_buf - shared buffer object 151 * @dbuf: dma_buf - shared buffer object.
151 * @dbuf_mapped: flag to show whether dbuf is mapped or not 152 * @dbuf_mapped: flag to show whether dbuf is mapped or not
152 * @bytesused: number of bytes occupied by data in the plane (payload) 153 * @bytesused: number of bytes occupied by data in the plane (payload).
153 * @length: size of this plane (NOT the payload) in bytes 154 * @length: size of this plane (NOT the payload) in bytes.
154 * @min_length: minimum required size of this plane (NOT the payload) in bytes. 155 * @min_length: minimum required size of this plane (NOT the payload) in bytes.
155 * @length is always greater or equal to @min_length. 156 * @length is always greater or equal to @min_length.
156 * @offset: when memory in the associated struct vb2_buffer is 157 * @m: Union with memtype-specific data.
157 * VB2_MEMORY_MMAP, equals the offset from the start of 158 * @m.offset: when memory in the associated struct vb2_buffer is
159 * %VB2_MEMORY_MMAP, equals the offset from the start of
158 * the device memory for this plane (or is a "cookie" that 160 * the device memory for this plane (or is a "cookie" that
159 * should be passed to mmap() called on the video node) 161 * should be passed to mmap() called on the video node).
160 * @userptr: when memory is VB2_MEMORY_USERPTR, a userspace pointer 162 * @m.userptr: when memory is %VB2_MEMORY_USERPTR, a userspace pointer
161 * pointing to this plane 163 * pointing to this plane.
162 * @fd: when memory is VB2_MEMORY_DMABUF, a userspace file 164 * @m.fd: when memory is %VB2_MEMORY_DMABUF, a userspace file
163 * descriptor associated with this plane 165 * descriptor associated with this plane.
164 * @m: Union with memtype-specific data (@offset, @userptr or
165 * @fd).
166 * @data_offset: offset in the plane to the start of data; usually 0, 166 * @data_offset: offset in the plane to the start of data; usually 0,
167 * unless there is a header in front of the data 167 * unless there is a header in front of the data.
168 *
168 * Should contain enough information to be able to cover all the fields 169 * Should contain enough information to be able to cover all the fields
169 * of struct v4l2_plane at videodev2.h 170 * of &struct v4l2_plane at videodev2.h.
170 */ 171 */
171struct vb2_plane { 172struct vb2_plane {
172 void *mem_priv; 173 void *mem_priv;
@@ -184,35 +185,35 @@ struct vb2_plane {
184}; 185};
185 186
186/** 187/**
187 * enum vb2_io_modes - queue access methods 188 * enum vb2_io_modes - queue access methods.
188 * @VB2_MMAP: driver supports MMAP with streaming API 189 * @VB2_MMAP: driver supports MMAP with streaming API.
189 * @VB2_USERPTR: driver supports USERPTR with streaming API 190 * @VB2_USERPTR: driver supports USERPTR with streaming API.
190 * @VB2_READ: driver supports read() style access 191 * @VB2_READ: driver supports read() style access.
191 * @VB2_WRITE: driver supports write() style access 192 * @VB2_WRITE: driver supports write() style access.
192 * @VB2_DMABUF: driver supports DMABUF with streaming API 193 * @VB2_DMABUF: driver supports DMABUF with streaming API.
193 */ 194 */
194enum vb2_io_modes { 195enum vb2_io_modes {
195 VB2_MMAP = (1 << 0), 196 VB2_MMAP = BIT(0),
196 VB2_USERPTR = (1 << 1), 197 VB2_USERPTR = BIT(1),
197 VB2_READ = (1 << 2), 198 VB2_READ = BIT(2),
198 VB2_WRITE = (1 << 3), 199 VB2_WRITE = BIT(3),
199 VB2_DMABUF = (1 << 4), 200 VB2_DMABUF = BIT(4),
200}; 201};
201 202
202/** 203/**
203 * enum vb2_buffer_state - current video buffer state 204 * enum vb2_buffer_state - current video buffer state.
204 * @VB2_BUF_STATE_DEQUEUED: buffer under userspace control 205 * @VB2_BUF_STATE_DEQUEUED: buffer under userspace control.
205 * @VB2_BUF_STATE_PREPARING: buffer is being prepared in videobuf 206 * @VB2_BUF_STATE_PREPARING: buffer is being prepared in videobuf.
206 * @VB2_BUF_STATE_PREPARED: buffer prepared in videobuf and by the driver 207 * @VB2_BUF_STATE_PREPARED: buffer prepared in videobuf and by the driver.
207 * @VB2_BUF_STATE_QUEUED: buffer queued in videobuf, but not in driver 208 * @VB2_BUF_STATE_QUEUED: buffer queued in videobuf, but not in driver.
208 * @VB2_BUF_STATE_REQUEUEING: re-queue a buffer to the driver 209 * @VB2_BUF_STATE_REQUEUEING: re-queue a buffer to the driver.
209 * @VB2_BUF_STATE_ACTIVE: buffer queued in driver and possibly used 210 * @VB2_BUF_STATE_ACTIVE: buffer queued in driver and possibly used
210 * in a hardware operation 211 * in a hardware operation.
211 * @VB2_BUF_STATE_DONE: buffer returned from driver to videobuf, but 212 * @VB2_BUF_STATE_DONE: buffer returned from driver to videobuf, but
212 * not yet dequeued to userspace 213 * not yet dequeued to userspace.
213 * @VB2_BUF_STATE_ERROR: same as above, but the operation on the buffer 214 * @VB2_BUF_STATE_ERROR: same as above, but the operation on the buffer
214 * has ended with an error, which will be reported 215 * has ended with an error, which will be reported
215 * to the userspace when it is dequeued 216 * to the userspace when it is dequeued.
216 */ 217 */
217enum vb2_buffer_state { 218enum vb2_buffer_state {
218 VB2_BUF_STATE_DEQUEUED, 219 VB2_BUF_STATE_DEQUEUED,
@@ -228,15 +229,15 @@ enum vb2_buffer_state {
228struct vb2_queue; 229struct vb2_queue;
229 230
230/** 231/**
231 * struct vb2_buffer - represents a video buffer 232 * struct vb2_buffer - represents a video buffer.
232 * @vb2_queue: the queue to which this driver belongs 233 * @vb2_queue: pointer to &struct vb2_queue with the queue to
233 * @index: id number of the buffer 234 * which this driver belongs.
234 * @type: buffer type 235 * @index: id number of the buffer.
235 * @memory: the method, in which the actual data is passed 236 * @type: buffer type.
237 * @memory: the method, in which the actual data is passed.
236 * @num_planes: number of planes in the buffer 238 * @num_planes: number of planes in the buffer
237 * on an internal driver queue 239 * on an internal driver queue.
238 * @planes: private per-plane information; do not change 240 * @timestamp: frame timestamp in ns.
239 * @timestamp: frame timestamp in ns
240 */ 241 */
241struct vb2_buffer { 242struct vb2_buffer {
242 struct vb2_queue *vb2_queue; 243 struct vb2_queue *vb2_queue;
@@ -244,7 +245,6 @@ struct vb2_buffer {
244 unsigned int type; 245 unsigned int type;
245 unsigned int memory; 246 unsigned int memory;
246 unsigned int num_planes; 247 unsigned int num_planes;
247 struct vb2_plane planes[VB2_MAX_PLANES];
248 u64 timestamp; 248 u64 timestamp;
249 249
250 /* private: internal use only 250 /* private: internal use only
@@ -254,9 +254,11 @@ struct vb2_buffer {
254 * all buffers queued from userspace 254 * all buffers queued from userspace
255 * done_entry: entry on the list that stores all buffers ready 255 * done_entry: entry on the list that stores all buffers ready
256 * to be dequeued to userspace 256 * to be dequeued to userspace
257 * vb2_plane: per-plane information; do not change
257 */ 258 */
258 enum vb2_buffer_state state; 259 enum vb2_buffer_state state;
259 260
261 struct vb2_plane planes[VB2_MAX_PLANES];
260 struct list_head queued_entry; 262 struct list_head queued_entry;
261 struct list_head done_entry; 263 struct list_head done_entry;
262#ifdef CONFIG_VIDEO_ADV_DEBUG 264#ifdef CONFIG_VIDEO_ADV_DEBUG
@@ -292,7 +294,7 @@ struct vb2_buffer {
292}; 294};
293 295
294/** 296/**
295 * struct vb2_ops - driver-specific callbacks 297 * struct vb2_ops - driver-specific callbacks.
296 * 298 *
297 * @queue_setup: called from VIDIOC_REQBUFS() and VIDIOC_CREATE_BUFS() 299 * @queue_setup: called from VIDIOC_REQBUFS() and VIDIOC_CREATE_BUFS()
298 * handlers before memory allocation. It can be called 300 * handlers before memory allocation. It can be called
@@ -358,8 +360,8 @@ struct vb2_buffer {
358 * the @buf_queue callback are to be returned by the driver 360 * the @buf_queue callback are to be returned by the driver
359 * by calling vb2_buffer_done() with %VB2_BUF_STATE_QUEUED. 361 * by calling vb2_buffer_done() with %VB2_BUF_STATE_QUEUED.
360 * If you need a minimum number of buffers before you can 362 * If you need a minimum number of buffers before you can
361 * start streaming, then set @min_buffers_needed in the 363 * start streaming, then set
362 * vb2_queue structure. If that is non-zero then 364 * &vb2_queue->min_buffers_needed. If that is non-zero then
363 * @start_streaming won't be called until at least that 365 * @start_streaming won't be called until at least that
364 * many buffers have been queued up by userspace. 366 * many buffers have been queued up by userspace.
365 * @stop_streaming: called when 'streaming' state must be disabled; driver 367 * @stop_streaming: called when 'streaming' state must be disabled; driver
@@ -396,18 +398,18 @@ struct vb2_ops {
396}; 398};
397 399
398/** 400/**
399 * struct vb2_buf_ops - driver-specific callbacks 401 * struct vb2_buf_ops - driver-specific callbacks.
400 * 402 *
401 * @verify_planes_array: Verify that a given user space structure contains 403 * @verify_planes_array: Verify that a given user space structure contains
402 * enough planes for the buffer. This is called 404 * enough planes for the buffer. This is called
403 * for each dequeued buffer. 405 * for each dequeued buffer.
404 * @fill_user_buffer: given a vb2_buffer fill in the userspace structure. 406 * @fill_user_buffer: given a &vb2_buffer fill in the userspace structure.
405 * For V4L2 this is a struct v4l2_buffer. 407 * For V4L2 this is a &struct v4l2_buffer.
406 * @fill_vb2_buffer: given a userspace structure, fill in the vb2_buffer. 408 * @fill_vb2_buffer: given a userspace structure, fill in the &vb2_buffer.
407 * If the userspace structure is invalid, then this op 409 * If the userspace structure is invalid, then this op
408 * will return an error. 410 * will return an error.
409 * @copy_timestamp: copy the timestamp from a userspace structure to 411 * @copy_timestamp: copy the timestamp from a userspace structure to
410 * the vb2_buffer struct. 412 * the &struct vb2_buffer.
411 */ 413 */
412struct vb2_buf_ops { 414struct vb2_buf_ops {
413 int (*verify_planes_array)(struct vb2_buffer *vb, const void *pb); 415 int (*verify_planes_array)(struct vb2_buffer *vb, const void *pb);
@@ -418,20 +420,21 @@ struct vb2_buf_ops {
418}; 420};
419 421
420/** 422/**
421 * struct vb2_queue - a videobuf queue 423 * struct vb2_queue - a videobuf queue.
422 * 424 *
423 * @type: private buffer type whose content is defined by the vb2-core 425 * @type: private buffer type whose content is defined by the vb2-core
424 * caller. For example, for V4L2, it should match 426 * caller. For example, for V4L2, it should match
425 * the types defined on enum &v4l2_buf_type 427 * the types defined on &enum v4l2_buf_type.
426 * @io_modes: supported io methods (see vb2_io_modes enum) 428 * @io_modes: supported io methods (see &enum vb2_io_modes).
429 * @alloc_devs: &struct device memory type/allocator-specific per-plane device
427 * @dev: device to use for the default allocation context if the driver 430 * @dev: device to use for the default allocation context if the driver
428 * doesn't fill in the @alloc_devs array. 431 * doesn't fill in the @alloc_devs array.
429 * @dma_attrs: DMA attributes to use for the DMA. 432 * @dma_attrs: DMA attributes to use for the DMA.
430 * @bidirectional: when this flag is set the DMA direction for the buffers of 433 * @bidirectional: when this flag is set the DMA direction for the buffers of
431 * this queue will be overridden with DMA_BIDIRECTIONAL direction. 434 * this queue will be overridden with %DMA_BIDIRECTIONAL direction.
432 * This is useful in cases where the hardware (firmware) writes to 435 * This is useful in cases where the hardware (firmware) writes to
433 * a buffer which is mapped as read (DMA_TO_DEVICE), or reads from 436 * a buffer which is mapped as read (%DMA_TO_DEVICE), or reads from
434 * buffer which is mapped for write (DMA_FROM_DEVICE) in order 437 * buffer which is mapped for write (%DMA_FROM_DEVICE) in order
435 * to satisfy some internal hardware restrictions or adds a padding 438 * to satisfy some internal hardware restrictions or adds a padding
436 * needed by the processing algorithm. In case the DMA mapping is 439 * needed by the processing algorithm. In case the DMA mapping is
437 * not bidirectional but the hardware (firmware) trying to access 440 * not bidirectional but the hardware (firmware) trying to access
@@ -440,10 +443,10 @@ struct vb2_buf_ops {
440 * @fileio_read_once: report EOF after reading the first buffer 443 * @fileio_read_once: report EOF after reading the first buffer
441 * @fileio_write_immediately: queue buffer after each write() call 444 * @fileio_write_immediately: queue buffer after each write() call
442 * @allow_zero_bytesused: allow bytesused == 0 to be passed to the driver 445 * @allow_zero_bytesused: allow bytesused == 0 to be passed to the driver
443 * @quirk_poll_must_check_waiting_for_buffers: Return POLLERR at poll when QBUF 446 * @quirk_poll_must_check_waiting_for_buffers: Return %POLLERR at poll when QBUF
444 * has not been called. This is a vb1 idiom that has been adopted 447 * has not been called. This is a vb1 idiom that has been adopted
445 * also by vb2. 448 * also by vb2.
446 * @lock: pointer to a mutex that protects the vb2_queue struct. The 449 * @lock: pointer to a mutex that protects the &struct vb2_queue. The
447 * driver can set this to a mutex to let the v4l2 core serialize 450 * driver can set this to a mutex to let the v4l2 core serialize
448 * the queuing ioctls. If the driver wants to handle locking 451 * the queuing ioctls. If the driver wants to handle locking
449 * itself, then this should be set to NULL. This lock is not used 452 * itself, then this should be set to NULL. This lock is not used
@@ -454,17 +457,17 @@ struct vb2_buf_ops {
454 * drivers to easily associate an owner filehandle with the queue. 457 * drivers to easily associate an owner filehandle with the queue.
455 * @ops: driver-specific callbacks 458 * @ops: driver-specific callbacks
456 * @mem_ops: memory allocator specific callbacks 459 * @mem_ops: memory allocator specific callbacks
457 * @buf_ops: callbacks to deliver buffer information 460 * @buf_ops: callbacks to deliver buffer information.
458 * between user-space and kernel-space 461 * between user-space and kernel-space.
459 * @drv_priv: driver private data 462 * @drv_priv: driver private data.
460 * @buf_struct_size: size of the driver-specific buffer structure; 463 * @buf_struct_size: size of the driver-specific buffer structure;
461 * "0" indicates the driver doesn't want to use a custom buffer 464 * "0" indicates the driver doesn't want to use a custom buffer
462 * structure type. for example, sizeof(struct vb2_v4l2_buffer) 465 * structure type. for example, ``sizeof(struct vb2_v4l2_buffer)``
463 * will be used for v4l2. 466 * will be used for v4l2.
464 * @timestamp_flags: Timestamp flags; V4L2_BUF_FLAG_TIMESTAMP_* and 467 * @timestamp_flags: Timestamp flags; ``V4L2_BUF_FLAG_TIMESTAMP_*`` and
465 * V4L2_BUF_FLAG_TSTAMP_SRC_* 468 * ``V4L2_BUF_FLAG_TSTAMP_SRC_*``
466 * @gfp_flags: additional gfp flags used when allocating the buffers. 469 * @gfp_flags: additional gfp flags used when allocating the buffers.
467 * Typically this is 0, but it may be e.g. GFP_DMA or __GFP_DMA32 470 * Typically this is 0, but it may be e.g. %GFP_DMA or %__GFP_DMA32
468 * to force the buffer allocation to a specific memory zone. 471 * to force the buffer allocation to a specific memory zone.
469 * @min_buffers_needed: the minimum number of buffers needed before 472 * @min_buffers_needed: the minimum number of buffers needed before
470 * @start_streaming can be called. Used when a DMA engine 473 * @start_streaming can be called. Used when a DMA engine
@@ -484,20 +487,19 @@ struct vb2_buf_ops {
484 * @done_list: list of buffers ready to be dequeued to userspace 487 * @done_list: list of buffers ready to be dequeued to userspace
485 * @done_lock: lock to protect done_list list 488 * @done_lock: lock to protect done_list list
486 * @done_wq: waitqueue for processes waiting for buffers ready to be dequeued 489 * @done_wq: waitqueue for processes waiting for buffers ready to be dequeued
487 * @alloc_devs: memory type/allocator-specific per-plane device
488 * @streaming: current streaming state 490 * @streaming: current streaming state
489 * @start_streaming_called: @start_streaming was called successfully and we 491 * @start_streaming_called: @start_streaming was called successfully and we
490 * started streaming. 492 * started streaming.
491 * @error: a fatal error occurred on the queue 493 * @error: a fatal error occurred on the queue
492 * @waiting_for_buffers: used in poll() to check if vb2 is still waiting for 494 * @waiting_for_buffers: used in poll() to check if vb2 is still waiting for
493 * buffers. Only set for capture queues if qbuf has not yet been 495 * buffers. Only set for capture queues if qbuf has not yet been
494 * called since poll() needs to return POLLERR in that situation. 496 * called since poll() needs to return %POLLERR in that situation.
495 * @is_multiplanar: set if buffer type is multiplanar 497 * @is_multiplanar: set if buffer type is multiplanar
496 * @is_output: set if buffer type is output 498 * @is_output: set if buffer type is output
497 * @copy_timestamp: set if vb2-core should set timestamps 499 * @copy_timestamp: set if vb2-core should set timestamps
498 * @last_buffer_dequeued: used in poll() and DQBUF to immediately return if the 500 * @last_buffer_dequeued: used in poll() and DQBUF to immediately return if the
499 * last decoded buffer was already dequeued. Set for capture queues 501 * last decoded buffer was already dequeued. Set for capture queues
500 * when a buffer with the V4L2_BUF_FLAG_LAST is dequeued. 502 * when a buffer with the %V4L2_BUF_FLAG_LAST is dequeued.
501 * @fileio: file io emulator internal data, used only if emulator is active 503 * @fileio: file io emulator internal data, used only if emulator is active
502 * @threadio: thread io internal data, used only if thread is active 504 * @threadio: thread io internal data, used only if thread is active
503 */ 505 */
@@ -525,6 +527,8 @@ struct vb2_queue {
525 gfp_t gfp_flags; 527 gfp_t gfp_flags;
526 u32 min_buffers_needed; 528 u32 min_buffers_needed;
527 529
530 struct device *alloc_devs[VB2_MAX_PLANES];
531
528 /* private: internal use only */ 532 /* private: internal use only */
529 struct mutex mmap_lock; 533 struct mutex mmap_lock;
530 unsigned int memory; 534 unsigned int memory;
@@ -540,8 +544,6 @@ struct vb2_queue {
540 spinlock_t done_lock; 544 spinlock_t done_lock;
541 wait_queue_head_t done_wq; 545 wait_queue_head_t done_wq;
542 546
543 struct device *alloc_devs[VB2_MAX_PLANES];
544
545 unsigned int streaming:1; 547 unsigned int streaming:1;
546 unsigned int start_streaming_called:1; 548 unsigned int start_streaming_called:1;
547 unsigned int error:1; 549 unsigned int error:1;
@@ -568,9 +570,10 @@ struct vb2_queue {
568}; 570};
569 571
570/** 572/**
571 * vb2_plane_vaddr() - Return a kernel virtual address of a given plane 573 * vb2_plane_vaddr() - Return a kernel virtual address of a given plane.
572 * @vb: vb2_buffer to which the plane in question belongs to 574 * @vb: pointer to &struct vb2_buffer to which the plane in
573 * @plane_no: plane number for which the address is to be returned 575 * question belongs to.
576 * @plane_no: plane number for which the address is to be returned.
574 * 577 *
575 * This function returns a kernel virtual address of a given plane if 578 * This function returns a kernel virtual address of a given plane if
576 * such a mapping exist, NULL otherwise. 579 * such a mapping exist, NULL otherwise.
@@ -578,9 +581,10 @@ struct vb2_queue {
578void *vb2_plane_vaddr(struct vb2_buffer *vb, unsigned int plane_no); 581void *vb2_plane_vaddr(struct vb2_buffer *vb, unsigned int plane_no);
579 582
580/** 583/**
581 * vb2_plane_cookie() - Return allocator specific cookie for the given plane 584 * vb2_plane_cookie() - Return allocator specific cookie for the given plane.
582 * @vb: vb2_buffer to which the plane in question belongs to 585 * @vb: pointer to &struct vb2_buffer to which the plane in
583 * @plane_no: plane number for which the cookie is to be returned 586 * question belongs to.
587 * @plane_no: plane number for which the cookie is to be returned.
584 * 588 *
585 * This function returns an allocator specific cookie for a given plane if 589 * This function returns an allocator specific cookie for a given plane if
586 * available, NULL otherwise. The allocator should provide some simple static 590 * available, NULL otherwise. The allocator should provide some simple static
@@ -591,9 +595,11 @@ void *vb2_plane_vaddr(struct vb2_buffer *vb, unsigned int plane_no);
591void *vb2_plane_cookie(struct vb2_buffer *vb, unsigned int plane_no); 595void *vb2_plane_cookie(struct vb2_buffer *vb, unsigned int plane_no);
592 596
593/** 597/**
594 * vb2_buffer_done() - inform videobuf that an operation on a buffer is finished 598 * vb2_buffer_done() - inform videobuf that an operation on a buffer
595 * @vb: vb2_buffer returned from the driver 599 * is finished.
596 * @state: either %VB2_BUF_STATE_DONE if the operation finished 600 * @vb: pointer to &struct vb2_buffer to be used.
601 * @state: state of the buffer, as defined by &enum vb2_buffer_state.
602 * Either %VB2_BUF_STATE_DONE if the operation finished
597 * successfully, %VB2_BUF_STATE_ERROR if the operation finished 603 * successfully, %VB2_BUF_STATE_ERROR if the operation finished
598 * with an error or %VB2_BUF_STATE_QUEUED if the driver wants to 604 * with an error or %VB2_BUF_STATE_QUEUED if the driver wants to
599 * requeue buffers. If start_streaming fails then it should return 605 * requeue buffers. If start_streaming fails then it should return
@@ -614,8 +620,8 @@ void *vb2_plane_cookie(struct vb2_buffer *vb, unsigned int plane_no);
614void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state); 620void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state);
615 621
616/** 622/**
617 * vb2_discard_done() - discard all buffers marked as DONE 623 * vb2_discard_done() - discard all buffers marked as DONE.
618 * @q: videobuf2 queue 624 * @q: pointer to &struct vb2_queue with videobuf2 queue.
619 * 625 *
620 * This function is intended to be used with suspend/resume operations. It 626 * This function is intended to be used with suspend/resume operations. It
621 * discards all 'done' buffers as they would be too old to be requested after 627 * discards all 'done' buffers as they would be too old to be requested after
@@ -628,74 +634,83 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state);
628void vb2_discard_done(struct vb2_queue *q); 634void vb2_discard_done(struct vb2_queue *q);
629 635
630/** 636/**
631 * vb2_wait_for_all_buffers() - wait until all buffers are given back to vb2 637 * vb2_wait_for_all_buffers() - wait until all buffers are given back to vb2.
632 * @q: videobuf2 queue 638 * @q: pointer to &struct vb2_queue with videobuf2 queue.
633 * 639 *
634 * This function will wait until all buffers that have been given to the driver 640 * This function will wait until all buffers that have been given to the driver
635 * by &vb2_ops->buf_queue are given back to vb2 with vb2_buffer_done(). It 641 * by &vb2_ops->buf_queue are given back to vb2 with vb2_buffer_done(). It
636 * doesn't call wait_prepare()/wait_finish() pair. It is intended to be called 642 * doesn't call &vb2_ops->wait_prepare/&vb2_ops->wait_finish pair.
637 * with all locks taken, for example from &vb2_ops->stop_streaming callback. 643 * It is intended to be called with all locks taken, for example from
644 * &vb2_ops->stop_streaming callback.
638 */ 645 */
639int vb2_wait_for_all_buffers(struct vb2_queue *q); 646int vb2_wait_for_all_buffers(struct vb2_queue *q);
640 647
641/** 648/**
642 * vb2_core_querybuf() - query video buffer information 649 * vb2_core_querybuf() - query video buffer information.
643 * @q: videobuf queue 650 * @q: pointer to &struct vb2_queue with videobuf2 queue.
644 * @index: id number of the buffer 651 * @index: id number of the buffer.
645 * @pb: buffer struct passed from userspace 652 * @pb: buffer struct passed from userspace.
653 *
654 * Videobuf2 core helper to implement VIDIOC_QUERYBUF() operation. It is called
655 * internally by VB2 by an API-specific handler, like ``videobuf2-v4l2.h``.
646 * 656 *
647 * Should be called from vidioc_querybuf ioctl handler in driver.
648 * The passed buffer should have been verified. 657 * The passed buffer should have been verified.
658 *
649 * This function fills the relevant information for the userspace. 659 * This function fills the relevant information for the userspace.
660 *
661 * Return: returns zero on success; an error code otherwise.
650 */ 662 */
651void vb2_core_querybuf(struct vb2_queue *q, unsigned int index, void *pb); 663void vb2_core_querybuf(struct vb2_queue *q, unsigned int index, void *pb);
652 664
653/** 665/**
654 * vb2_core_reqbufs() - Initiate streaming 666 * vb2_core_reqbufs() - Initiate streaming.
655 * @q: videobuf2 queue 667 * @q: pointer to &struct vb2_queue with videobuf2 queue.
656 * @memory: memory type 668 * @memory: memory type, as defined by &enum vb2_memory.
657 * @count: requested buffer count 669 * @count: requested buffer count.
658 * 670 *
659 * Should be called from vidioc_reqbufs ioctl handler of a driver. 671 * Videobuf2 core helper to implement VIDIOC_REQBUF() operation. It is called
672 * internally by VB2 by an API-specific handler, like ``videobuf2-v4l2.h``.
660 * 673 *
661 * This function: 674 * This function:
662 * 675 *
663 * #) verifies streaming parameters passed from the userspace, 676 * #) verifies streaming parameters passed from the userspace;
664 * #) sets up the queue, 677 * #) sets up the queue;
665 * #) negotiates number of buffers and planes per buffer with the driver 678 * #) negotiates number of buffers and planes per buffer with the driver
666 * to be used during streaming, 679 * to be used during streaming;
667 * #) allocates internal buffer structures (struct vb2_buffer), according to 680 * #) allocates internal buffer structures (&struct vb2_buffer), according to
668 * the agreed parameters, 681 * the agreed parameters;
669 * #) for MMAP memory type, allocates actual video memory, using the 682 * #) for MMAP memory type, allocates actual video memory, using the
670 * memory handling/allocation routines provided during queue initialization 683 * memory handling/allocation routines provided during queue initialization.
671 * 684 *
672 * If req->count is 0, all the memory will be freed instead. 685 * If req->count is 0, all the memory will be freed instead.
673 * If the queue has been allocated previously (by a previous vb2_reqbufs) call
674 * and the queue is not busy, memory will be reallocated.
675 * 686 *
676 * The return values from this function are intended to be directly returned 687 * If the queue has been allocated previously by a previous vb2_core_reqbufs()
677 * from vidioc_reqbufs handler in driver. 688 * call and the queue is not busy, memory will be reallocated.
689 *
690 * Return: returns zero on success; an error code otherwise.
678 */ 691 */
679int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory, 692int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,
680 unsigned int *count); 693 unsigned int *count);
681 694
682/** 695/**
683 * vb2_core_create_bufs() - Allocate buffers and any required auxiliary structs 696 * vb2_core_create_bufs() - Allocate buffers and any required auxiliary structs
684 * @q: videobuf2 queue 697 * @q: pointer to &struct vb2_queue with videobuf2 queue.
685 * @memory: memory type 698 * @memory: memory type, as defined by &enum vb2_memory.
686 * @count: requested buffer count 699 * @count: requested buffer count.
687 * @requested_planes: number of planes requested 700 * @requested_planes: number of planes requested.
688 * @requested_sizes: array with the size of the planes 701 * @requested_sizes: array with the size of the planes.
702 *
703 * Videobuf2 core helper to implement VIDIOC_CREATE_BUFS() operation. It is
704 * called internally by VB2 by an API-specific handler, like
705 * ``videobuf2-v4l2.h``.
689 * 706 *
690 * Should be called from VIDIOC_CREATE_BUFS() ioctl handler of a driver.
691 * This function: 707 * This function:
692 * 708 *
693 * #) verifies parameter sanity 709 * #) verifies parameter sanity;
694 * #) calls the .queue_setup() queue operation 710 * #) calls the &vb2_ops->queue_setup queue operation;
695 * #) performs any necessary memory allocations 711 * #) performs any necessary memory allocations.
696 * 712 *
697 * Return: the return values from this function are intended to be directly 713 * Return: returns zero on success; an error code otherwise.
698 * returned from VIDIOC_CREATE_BUFS() handler in driver.
699 */ 714 */
700int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, 715int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory,
701 unsigned int *count, unsigned int requested_planes, 716 unsigned int *count, unsigned int requested_planes,
@@ -703,57 +718,61 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory,
703 718
704/** 719/**
705 * vb2_core_prepare_buf() - Pass ownership of a buffer from userspace 720 * vb2_core_prepare_buf() - Pass ownership of a buffer from userspace
706 * to the kernel 721 * to the kernel.
707 * @q: videobuf2 queue 722 * @q: pointer to &struct vb2_queue with videobuf2 queue.
708 * @index: id number of the buffer 723 * @index: id number of the buffer.
709 * @pb: buffer structure passed from userspace to vidioc_prepare_buf 724 * @pb: buffer structure passed from userspace to
710 * handler in driver 725 * &v4l2_ioctl_ops->vidioc_prepare_buf handler in driver.
726 *
727 * Videobuf2 core helper to implement VIDIOC_PREPARE_BUF() operation. It is
728 * called internally by VB2 by an API-specific handler, like
729 * ``videobuf2-v4l2.h``.
711 * 730 *
712 * Should be called from vidioc_prepare_buf ioctl handler of a driver.
713 * The passed buffer should have been verified. 731 * The passed buffer should have been verified.
714 * This function calls buf_prepare callback in the driver (if provided),
715 * in which driver-specific buffer initialization can be performed,
716 * 732 *
717 * The return values from this function are intended to be directly returned 733 * This function calls vb2_ops->buf_prepare callback in the driver
718 * from vidioc_prepare_buf handler in driver. 734 * (if provided), in which driver-specific buffer initialization can
735 * be performed.
736 *
737 * Return: returns zero on success; an error code otherwise.
719 */ 738 */
720int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb); 739int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb);
721 740
722/** 741/**
723 * vb2_core_qbuf() - Queue a buffer from userspace 742 * vb2_core_qbuf() - Queue a buffer from userspace
724 * 743 *
725 * @q: videobuf2 queue 744 * @q: pointer to &struct vb2_queue with videobuf2 queue.
726 * @index: id number of the buffer 745 * @index: id number of the buffer
727 * @pb: buffer structure passed from userspace to vidioc_qbuf handler 746 * @pb: buffer structure passed from userspace to
728 * in driver 747 * v4l2_ioctl_ops->vidioc_qbuf handler in driver
729 * 748 *
730 * Should be called from vidioc_qbuf ioctl handler of a driver. 749 * Videobuf2 core helper to implement VIDIOC_QBUF() operation. It is called
731 * The passed buffer should have been verified. 750 * internally by VB2 by an API-specific handler, like ``videobuf2-v4l2.h``.
732 * 751 *
733 * This function: 752 * This function:
734 * 753 *
735 * #) if necessary, calls buf_prepare callback in the driver (if provided), in 754 * #) if necessary, calls &vb2_ops->buf_prepare callback in the driver
736 * which driver-specific buffer initialization can be performed, 755 * (if provided), in which driver-specific buffer initialization can
756 * be performed;
737 * #) if streaming is on, queues the buffer in driver by the means of 757 * #) if streaming is on, queues the buffer in driver by the means of
738 * &vb2_ops->buf_queue callback for processing. 758 * &vb2_ops->buf_queue callback for processing.
739 * 759 *
740 * The return values from this function are intended to be directly returned 760 * Return: returns zero on success; an error code otherwise.
741 * from vidioc_qbuf handler in driver.
742 */ 761 */
743int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb); 762int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb);
744 763
745/** 764/**
746 * vb2_core_dqbuf() - Dequeue a buffer to the userspace 765 * vb2_core_dqbuf() - Dequeue a buffer to the userspace
747 * @q: videobuf2 queue 766 * @q: pointer to &struct vb2_queue with videobuf2 queue
748 * @pindex: pointer to the buffer index. May be NULL 767 * @pindex: pointer to the buffer index. May be NULL
749 * @pb: buffer structure passed from userspace to vidioc_dqbuf handler 768 * @pb: buffer structure passed from userspace to
750 * in driver 769 * v4l2_ioctl_ops->vidioc_dqbuf handler in driver.
751 * @nonblocking: if true, this call will not sleep waiting for a buffer if no 770 * @nonblocking: if true, this call will not sleep waiting for a buffer if no
752 * buffers ready for dequeuing are present. Normally the driver 771 * buffers ready for dequeuing are present. Normally the driver
753 * would be passing (file->f_flags & O_NONBLOCK) here 772 * would be passing (file->f_flags & O_NONBLOCK) here.
754 * 773 *
755 * Should be called from vidioc_dqbuf ioctl handler of a driver. 774 * Videobuf2 core helper to implement VIDIOC_DQBUF() operation. It is called
756 * The passed buffer should have been verified. 775 * internally by VB2 by an API-specific handler, like ``videobuf2-v4l2.h``.
757 * 776 *
758 * This function: 777 * This function:
759 * 778 *
@@ -763,73 +782,108 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb);
763 * #) the buffer struct members are filled with relevant information for 782 * #) the buffer struct members are filled with relevant information for
764 * the userspace. 783 * the userspace.
765 * 784 *
766 * The return values from this function are intended to be directly returned 785 * Return: returns zero on success; an error code otherwise.
767 * from vidioc_dqbuf handler in driver.
768 */ 786 */
769int vb2_core_dqbuf(struct vb2_queue *q, unsigned int *pindex, void *pb, 787int vb2_core_dqbuf(struct vb2_queue *q, unsigned int *pindex, void *pb,
770 bool nonblocking); 788 bool nonblocking);
771 789
790/**
791 * vb2_core_streamon() - Implements VB2 stream ON logic
792 *
793 * @q: pointer to &struct vb2_queue with videobuf2 queue
794 * @type: type of the queue to be started.
795 * For V4L2, this is defined by &enum v4l2_buf_type type.
796 *
797 * Videobuf2 core helper to implement VIDIOC_STREAMON() operation. It is called
798 * internally by VB2 by an API-specific handler, like ``videobuf2-v4l2.h``.
799 *
800 * Return: returns zero on success; an error code otherwise.
801 */
772int vb2_core_streamon(struct vb2_queue *q, unsigned int type); 802int vb2_core_streamon(struct vb2_queue *q, unsigned int type);
803
804/**
805 * vb2_core_streamoff() - Implements VB2 stream OFF logic
806 *
807 * @q: pointer to &struct vb2_queue with videobuf2 queue
808 * @type: type of the queue to be started.
809 * For V4L2, this is defined by &enum v4l2_buf_type type.
810 *
811 * Videobuf2 core helper to implement VIDIOC_STREAMOFF() operation. It is
812 * called internally by VB2 by an API-specific handler, like
813 * ``videobuf2-v4l2.h``.
814 *
815 * Return: returns zero on success; an error code otherwise.
816 */
773int vb2_core_streamoff(struct vb2_queue *q, unsigned int type); 817int vb2_core_streamoff(struct vb2_queue *q, unsigned int type);
774 818
775/** 819/**
776 * vb2_core_expbuf() - Export a buffer as a file descriptor 820 * vb2_core_expbuf() - Export a buffer as a file descriptor.
777 * @q: videobuf2 queue 821 * @q: pointer to &struct vb2_queue with videobuf2 queue.
778 * @fd: file descriptor associated with DMABUF (set by driver) * 822 * @fd: pointer to the file descriptor associated with DMABUF
779 * @type: buffer type 823 * (set by driver).
780 * @index: id number of the buffer 824 * @type: buffer type.
825 * @index: id number of the buffer.
781 * @plane: index of the plane to be exported, 0 for single plane queues 826 * @plane: index of the plane to be exported, 0 for single plane queues
782 * @flags: flags for newly created file, currently only O_CLOEXEC is 827 * @flags: file flags for newly created file, as defined at
783 * supported, refer to manual of open syscall for more details 828 * include/uapi/asm-generic/fcntl.h.
829 * Currently, the only used flag is %O_CLOEXEC.
830 * is supported, refer to manual of open syscall for more details.
784 * 831 *
785 * The return values from this function are intended to be directly returned 832 *
786 * from vidioc_expbuf handler in driver. 833 * Videobuf2 core helper to implement VIDIOC_EXPBUF() operation. It is called
834 * internally by VB2 by an API-specific handler, like ``videobuf2-v4l2.h``.
835 *
836 * Return: returns zero on success; an error code otherwise.
787 */ 837 */
788int vb2_core_expbuf(struct vb2_queue *q, int *fd, unsigned int type, 838int vb2_core_expbuf(struct vb2_queue *q, int *fd, unsigned int type,
789 unsigned int index, unsigned int plane, unsigned int flags); 839 unsigned int index, unsigned int plane, unsigned int flags);
790 840
791/** 841/**
792 * vb2_core_queue_init() - initialize a videobuf2 queue 842 * vb2_core_queue_init() - initialize a videobuf2 queue
793 * @q: videobuf2 queue; this structure should be allocated in driver 843 * @q: pointer to &struct vb2_queue with videobuf2 queue.
844 * This structure should be allocated in driver
794 * 845 *
795 * The vb2_queue structure should be allocated by the driver. The driver is 846 * The &vb2_queue structure should be allocated by the driver. The driver is
796 * responsible of clearing it's content and setting initial values for some 847 * responsible of clearing it's content and setting initial values for some
797 * required entries before calling this function. 848 * required entries before calling this function.
798 * q->ops, q->mem_ops, q->type and q->io_modes are mandatory. Please refer 849 *
799 * to the struct vb2_queue description in include/media/videobuf2-core.h 850 * .. note::
800 * for more information. 851 *
852 * The following fields at @q should be set before calling this function:
853 * &vb2_queue->ops, &vb2_queue->mem_ops, &vb2_queue->type.
801 */ 854 */
802int vb2_core_queue_init(struct vb2_queue *q); 855int vb2_core_queue_init(struct vb2_queue *q);
803 856
804/** 857/**
805 * vb2_core_queue_release() - stop streaming, release the queue and free memory 858 * vb2_core_queue_release() - stop streaming, release the queue and free memory
806 * @q: videobuf2 queue 859 * @q: pointer to &struct vb2_queue with videobuf2 queue.
807 * 860 *
808 * This function stops streaming and performs necessary clean ups, including 861 * This function stops streaming and performs necessary clean ups, including
809 * freeing video buffer memory. The driver is responsible for freeing 862 * freeing video buffer memory. The driver is responsible for freeing
810 * the vb2_queue structure itself. 863 * the &struct vb2_queue itself.
811 */ 864 */
812void vb2_core_queue_release(struct vb2_queue *q); 865void vb2_core_queue_release(struct vb2_queue *q);
813 866
814/** 867/**
815 * vb2_queue_error() - signal a fatal error on the queue 868 * vb2_queue_error() - signal a fatal error on the queue
816 * @q: videobuf2 queue 869 * @q: pointer to &struct vb2_queue with videobuf2 queue.
817 * 870 *
818 * Flag that a fatal unrecoverable error has occurred and wake up all processes 871 * Flag that a fatal unrecoverable error has occurred and wake up all processes
819 * waiting on the queue. Polling will now set POLLERR and queuing and dequeuing 872 * waiting on the queue. Polling will now set %POLLERR and queuing and dequeuing
820 * buffers will return -EIO. 873 * buffers will return %-EIO.
821 * 874 *
822 * The error flag will be cleared when cancelling the queue, either from 875 * The error flag will be cleared when canceling the queue, either from
823 * vb2_streamoff or vb2_queue_release. Drivers should thus not call this 876 * vb2_streamoff() or vb2_queue_release(). Drivers should thus not call this
824 * function before starting the stream, otherwise the error flag will remain set 877 * function before starting the stream, otherwise the error flag will remain set
825 * until the queue is released when closing the device node. 878 * until the queue is released when closing the device node.
826 */ 879 */
827void vb2_queue_error(struct vb2_queue *q); 880void vb2_queue_error(struct vb2_queue *q);
828 881
829/** 882/**
830 * vb2_mmap() - map video buffers into application address space 883 * vb2_mmap() - map video buffers into application address space.
831 * @q: videobuf2 queue 884 * @q: pointer to &struct vb2_queue with videobuf2 queue.
832 * @vma: vma passed to the mmap file operation handler in the driver 885 * @vma: pointer to &struct vm_area_struct with the vma passed
886 * to the mmap file operation handler in the driver.
833 * 887 *
834 * Should be called from mmap file operation handler of a driver. 888 * Should be called from mmap file operation handler of a driver.
835 * This function maps one plane of one of the available video buffers to 889 * This function maps one plane of one of the available video buffers to
@@ -837,8 +891,10 @@ void vb2_queue_error(struct vb2_queue *q);
837 * has to be called once per each plane per each buffer previously allocated. 891 * has to be called once per each plane per each buffer previously allocated.
838 * 892 *
839 * When the userspace application calls mmap, it passes to it an offset returned 893 * When the userspace application calls mmap, it passes to it an offset returned
840 * to it earlier by the means of vidioc_querybuf handler. That offset acts as 894 * to it earlier by the means of &v4l2_ioctl_ops->vidioc_querybuf handler.
841 * a "cookie", which is then used to identify the plane to be mapped. 895 * That offset acts as a "cookie", which is then used to identify the plane
896 * to be mapped.
897 *
842 * This function finds a plane with a matching offset and a mapping is performed 898 * This function finds a plane with a matching offset and a mapping is performed
843 * by the means of a provided memory operation. 899 * by the means of a provided memory operation.
844 * 900 *
@@ -848,6 +904,21 @@ void vb2_queue_error(struct vb2_queue *q);
848int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma); 904int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma);
849 905
850#ifndef CONFIG_MMU 906#ifndef CONFIG_MMU
907/**
908 * vb2_get_unmapped_area - map video buffers into application address space.
909 * @q: pointer to &struct vb2_queue with videobuf2 queue.
910 * @addr: memory address.
911 * @len: buffer size.
912 * @pgoff: page offset.
913 * @flags: memory flags.
914 *
915 * This function is used in noMMU platforms to propose address mapping
916 * for a given buffer. It's intended to be used as a handler for the
917 * &file_operations->get_unmapped_area operation.
918 *
919 * This is called by the mmap() syscall routines will call this
920 * to get a proposed address for the mapping, when ``!CONFIG_MMU``.
921 */
851unsigned long vb2_get_unmapped_area(struct vb2_queue *q, 922unsigned long vb2_get_unmapped_area(struct vb2_queue *q,
852 unsigned long addr, 923 unsigned long addr,
853 unsigned long len, 924 unsigned long len,
@@ -856,10 +927,12 @@ unsigned long vb2_get_unmapped_area(struct vb2_queue *q,
856#endif 927#endif
857 928
858/** 929/**
859 * vb2_core_poll() - implements poll userspace operation 930 * vb2_core_poll() - implements poll syscall() logic.
860 * @q: videobuf2 queue 931 * @q: pointer to &struct vb2_queue with videobuf2 queue.
861 * @file: file argument passed to the poll file operation handler 932 * @file: &struct file argument passed to the poll
862 * @wait: wait argument passed to the poll file operation handler 933 * file operation handler.
934 * @wait: &poll_table wait argument passed to the poll
935 * file operation handler.
863 * 936 *
864 * This function implements poll file operation handler for a driver. 937 * This function implements poll file operation handler for a driver.
865 * For CAPTURE queues, if a buffer is ready to be dequeued, the userspace will 938 * For CAPTURE queues, if a buffer is ready to be dequeued, the userspace will
@@ -874,16 +947,32 @@ unsigned long vb2_get_unmapped_area(struct vb2_queue *q,
874__poll_t vb2_core_poll(struct vb2_queue *q, struct file *file, 947__poll_t vb2_core_poll(struct vb2_queue *q, struct file *file,
875 poll_table *wait); 948 poll_table *wait);
876 949
950/**
951 * vb2_read() - implements read() syscall logic.
952 * @q: pointer to &struct vb2_queue with videobuf2 queue.
953 * @data: pointed to target userspace buffer
954 * @count: number of bytes to read
955 * @ppos: file handle position tracking pointer
956 * @nonblock: mode selector (1 means blocking calls, 0 means nonblocking)
957 */
877size_t vb2_read(struct vb2_queue *q, char __user *data, size_t count, 958size_t vb2_read(struct vb2_queue *q, char __user *data, size_t count,
878 loff_t *ppos, int nonblock); 959 loff_t *ppos, int nonblock);
960/**
961 * vb2_read() - implements write() syscall logic.
962 * @q: pointer to &struct vb2_queue with videobuf2 queue.
963 * @data: pointed to target userspace buffer
964 * @count: number of bytes to write
965 * @ppos: file handle position tracking pointer
966 * @nonblock: mode selector (1 means blocking calls, 0 means nonblocking)
967 */
879size_t vb2_write(struct vb2_queue *q, const char __user *data, size_t count, 968size_t vb2_write(struct vb2_queue *q, const char __user *data, size_t count,
880 loff_t *ppos, int nonblock); 969 loff_t *ppos, int nonblock);
881 970
882/** 971/**
883 * typedef vb2_thread_fnc - callback function for use with vb2_thread 972 * typedef vb2_thread_fnc - callback function for use with vb2_thread.
884 * 973 *
885 * @vb: pointer to struct &vb2_buffer 974 * @vb: pointer to struct &vb2_buffer.
886 * @priv: pointer to a private pointer 975 * @priv: pointer to a private data.
887 * 976 *
888 * This is called whenever a buffer is dequeued in the thread. 977 * This is called whenever a buffer is dequeued in the thread.
889 */ 978 */
@@ -891,13 +980,13 @@ typedef int (*vb2_thread_fnc)(struct vb2_buffer *vb, void *priv);
891 980
892/** 981/**
893 * vb2_thread_start() - start a thread for the given queue. 982 * vb2_thread_start() - start a thread for the given queue.
894 * @q: videobuf queue 983 * @q: pointer to &struct vb2_queue with videobuf2 queue.
895 * @fnc: callback function 984 * @fnc: &vb2_thread_fnc callback function.
896 * @priv: priv pointer passed to the callback function 985 * @priv: priv pointer passed to the callback function.
897 * @thread_name:the name of the thread. This will be prefixed with "vb2-". 986 * @thread_name:the name of the thread. This will be prefixed with "vb2-".
898 * 987 *
899 * This starts a thread that will queue and dequeue until an error occurs 988 * This starts a thread that will queue and dequeue until an error occurs
900 * or @vb2_thread_stop is called. 989 * or vb2_thread_stop() is called.
901 * 990 *
902 * .. attention:: 991 * .. attention::
903 * 992 *
@@ -910,13 +999,13 @@ int vb2_thread_start(struct vb2_queue *q, vb2_thread_fnc fnc, void *priv,
910 999
911/** 1000/**
912 * vb2_thread_stop() - stop the thread for the given queue. 1001 * vb2_thread_stop() - stop the thread for the given queue.
913 * @q: videobuf queue 1002 * @q: pointer to &struct vb2_queue with videobuf2 queue.
914 */ 1003 */
915int vb2_thread_stop(struct vb2_queue *q); 1004int vb2_thread_stop(struct vb2_queue *q);
916 1005
917/** 1006/**
918 * vb2_is_streaming() - return streaming status of the queue 1007 * vb2_is_streaming() - return streaming status of the queue.
919 * @q: videobuf queue 1008 * @q: pointer to &struct vb2_queue with videobuf2 queue.
920 */ 1009 */
921static inline bool vb2_is_streaming(struct vb2_queue *q) 1010static inline bool vb2_is_streaming(struct vb2_queue *q)
922{ 1011{
@@ -925,15 +1014,16 @@ static inline bool vb2_is_streaming(struct vb2_queue *q)
925 1014
926/** 1015/**
927 * vb2_fileio_is_active() - return true if fileio is active. 1016 * vb2_fileio_is_active() - return true if fileio is active.
928 * @q: videobuf queue 1017 * @q: pointer to &struct vb2_queue with videobuf2 queue.
929 * 1018 *
930 * This returns true if read() or write() is used to stream the data 1019 * This returns true if read() or write() is used to stream the data
931 * as opposed to stream I/O. This is almost never an important distinction, 1020 * as opposed to stream I/O. This is almost never an important distinction,
932 * except in rare cases. One such case is that using read() or write() to 1021 * except in rare cases. One such case is that using read() or write() to
933 * stream a format using V4L2_FIELD_ALTERNATE is not allowed since there 1022 * stream a format using %V4L2_FIELD_ALTERNATE is not allowed since there
934 * is no way you can pass the field information of each buffer to/from 1023 * is no way you can pass the field information of each buffer to/from
935 * userspace. A driver that supports this field format should check for 1024 * userspace. A driver that supports this field format should check for
936 * this in the queue_setup op and reject it if this function returns true. 1025 * this in the &vb2_ops->queue_setup op and reject it if this function returns
1026 * true.
937 */ 1027 */
938static inline bool vb2_fileio_is_active(struct vb2_queue *q) 1028static inline bool vb2_fileio_is_active(struct vb2_queue *q)
939{ 1029{
@@ -941,8 +1031,8 @@ static inline bool vb2_fileio_is_active(struct vb2_queue *q)
941} 1031}
942 1032
943/** 1033/**
944 * vb2_is_busy() - return busy status of the queue 1034 * vb2_is_busy() - return busy status of the queue.
945 * @q: videobuf queue 1035 * @q: pointer to &struct vb2_queue with videobuf2 queue.
946 * 1036 *
947 * This function checks if queue has any buffers allocated. 1037 * This function checks if queue has any buffers allocated.
948 */ 1038 */
@@ -952,8 +1042,8 @@ static inline bool vb2_is_busy(struct vb2_queue *q)
952} 1042}
953 1043
954/** 1044/**
955 * vb2_get_drv_priv() - return driver private data associated with the queue 1045 * vb2_get_drv_priv() - return driver private data associated with the queue.
956 * @q: videobuf queue 1046 * @q: pointer to &struct vb2_queue with videobuf2 queue.
957 */ 1047 */
958static inline void *vb2_get_drv_priv(struct vb2_queue *q) 1048static inline void *vb2_get_drv_priv(struct vb2_queue *q)
959{ 1049{
@@ -961,10 +1051,11 @@ static inline void *vb2_get_drv_priv(struct vb2_queue *q)
961} 1051}
962 1052
963/** 1053/**
964 * vb2_set_plane_payload() - set bytesused for the plane plane_no 1054 * vb2_set_plane_payload() - set bytesused for the plane @plane_no.
965 * @vb: buffer for which plane payload should be set 1055 * @vb: pointer to &struct vb2_buffer to which the plane in
966 * @plane_no: plane number for which payload should be set 1056 * question belongs to.
967 * @size: payload in bytes 1057 * @plane_no: plane number for which payload should be set.
1058 * @size: payload in bytes.
968 */ 1059 */
969static inline void vb2_set_plane_payload(struct vb2_buffer *vb, 1060static inline void vb2_set_plane_payload(struct vb2_buffer *vb,
970 unsigned int plane_no, unsigned long size) 1061 unsigned int plane_no, unsigned long size)
@@ -975,8 +1066,9 @@ static inline void vb2_set_plane_payload(struct vb2_buffer *vb,
975 1066
976/** 1067/**
977 * vb2_get_plane_payload() - get bytesused for the plane plane_no 1068 * vb2_get_plane_payload() - get bytesused for the plane plane_no
978 * @vb: buffer for which plane payload should be set 1069 * @vb: pointer to &struct vb2_buffer to which the plane in
979 * @plane_no: plane number for which payload should be set 1070 * question belongs to.
1071 * @plane_no: plane number for which payload should be set.
980 */ 1072 */
981static inline unsigned long vb2_get_plane_payload(struct vb2_buffer *vb, 1073static inline unsigned long vb2_get_plane_payload(struct vb2_buffer *vb,
982 unsigned int plane_no) 1074 unsigned int plane_no)
@@ -987,9 +1079,10 @@ static inline unsigned long vb2_get_plane_payload(struct vb2_buffer *vb,
987} 1079}
988 1080
989/** 1081/**
990 * vb2_plane_size() - return plane size in bytes 1082 * vb2_plane_size() - return plane size in bytes.
991 * @vb: buffer for which plane size should be returned 1083 * @vb: pointer to &struct vb2_buffer to which the plane in
992 * @plane_no: plane number for which size should be returned 1084 * question belongs to.
1085 * @plane_no: plane number for which size should be returned.
993 */ 1086 */
994static inline unsigned long 1087static inline unsigned long
995vb2_plane_size(struct vb2_buffer *vb, unsigned int plane_no) 1088vb2_plane_size(struct vb2_buffer *vb, unsigned int plane_no)
@@ -1000,8 +1093,8 @@ vb2_plane_size(struct vb2_buffer *vb, unsigned int plane_no)
1000} 1093}
1001 1094
1002/** 1095/**
1003 * vb2_start_streaming_called() - return streaming status of driver 1096 * vb2_start_streaming_called() - return streaming status of driver.
1004 * @q: videobuf queue 1097 * @q: pointer to &struct vb2_queue with videobuf2 queue.
1005 */ 1098 */
1006static inline bool vb2_start_streaming_called(struct vb2_queue *q) 1099static inline bool vb2_start_streaming_called(struct vb2_queue *q)
1007{ 1100{
@@ -1009,8 +1102,8 @@ static inline bool vb2_start_streaming_called(struct vb2_queue *q)
1009} 1102}
1010 1103
1011/** 1104/**
1012 * vb2_clear_last_buffer_dequeued() - clear last buffer dequeued flag of queue 1105 * vb2_clear_last_buffer_dequeued() - clear last buffer dequeued flag of queue.
1013 * @q: videobuf queue 1106 * @q: pointer to &struct vb2_queue with videobuf2 queue.
1014 */ 1107 */
1015static inline void vb2_clear_last_buffer_dequeued(struct vb2_queue *q) 1108static inline void vb2_clear_last_buffer_dequeued(struct vb2_queue *q)
1016{ 1109{
@@ -1024,10 +1117,10 @@ static inline void vb2_clear_last_buffer_dequeued(struct vb2_queue *q)
1024 1117
1025/** 1118/**
1026 * vb2_buffer_in_use() - return true if the buffer is in use and 1119 * vb2_buffer_in_use() - return true if the buffer is in use and
1027 * the queue cannot be freed (by the means of REQBUFS(0)) call 1120 * the queue cannot be freed (by the means of VIDIOC_REQBUFS(0)) call.
1028 * 1121 *
1029 * @vb: buffer for which plane size should be returned 1122 * @vb: buffer for which plane size should be returned.
1030 * @q: videobuf queue 1123 * @q: pointer to &struct vb2_queue with videobuf2 queue.
1031 */ 1124 */
1032bool vb2_buffer_in_use(struct vb2_queue *q, struct vb2_buffer *vb); 1125bool vb2_buffer_in_use(struct vb2_queue *q, struct vb2_buffer *vb);
1033 1126
@@ -1035,11 +1128,11 @@ bool vb2_buffer_in_use(struct vb2_queue *q, struct vb2_buffer *vb);
1035 * vb2_verify_memory_type() - Check whether the memory type and buffer type 1128 * vb2_verify_memory_type() - Check whether the memory type and buffer type
1036 * passed to a buffer operation are compatible with the queue. 1129 * passed to a buffer operation are compatible with the queue.
1037 * 1130 *
1038 * @q: videobuf queue 1131 * @q: pointer to &struct vb2_queue with videobuf2 queue.
1039 * @memory: memory model, as defined by enum &vb2_memory. 1132 * @memory: memory model, as defined by enum &vb2_memory.
1040 * @type: private buffer type whose content is defined by the vb2-core 1133 * @type: private buffer type whose content is defined by the vb2-core
1041 * caller. For example, for V4L2, it should match 1134 * caller. For example, for V4L2, it should match
1042 * the types defined on enum &v4l2_buf_type 1135 * the types defined on enum &v4l2_buf_type.
1043 */ 1136 */
1044int vb2_verify_memory_type(struct vb2_queue *q, 1137int vb2_verify_memory_type(struct vb2_queue *q,
1045 enum vb2_memory memory, unsigned int type); 1138 enum vb2_memory memory, unsigned int type);
diff --git a/include/media/videobuf2-dvb.h b/include/media/videobuf2-dvb.h
index 5a31faa24f1a..8605366ec87c 100644
--- a/include/media/videobuf2-dvb.h
+++ b/include/media/videobuf2-dvb.h
@@ -2,12 +2,11 @@
2#ifndef _VIDEOBUF2_DVB_H_ 2#ifndef _VIDEOBUF2_DVB_H_
3#define _VIDEOBUF2_DVB_H_ 3#define _VIDEOBUF2_DVB_H_
4 4
5#include <dvbdev.h> 5#include <media/dvbdev.h>
6#include <dmxdev.h> 6#include <media/dmxdev.h>
7#include <dvb_demux.h> 7#include <media/dvb_demux.h>
8#include <dvb_net.h> 8#include <media/dvb_net.h>
9#include <dvb_frontend.h> 9#include <media/dvb_frontend.h>
10
11#include <media/videobuf2-v4l2.h> 10#include <media/videobuf2-v4l2.h>
12 11
13/* We don't actually need to include media-device.h here */ 12/* We don't actually need to include media-device.h here */
diff --git a/include/media/videobuf2-memops.h b/include/media/videobuf2-memops.h
index a6ed091b79ce..4b5b84f93538 100644
--- a/include/media/videobuf2-memops.h
+++ b/include/media/videobuf2-memops.h
@@ -19,11 +19,11 @@
19#include <linux/refcount.h> 19#include <linux/refcount.h>
20 20
21/** 21/**
22 * struct vb2_vmarea_handler - common vma refcount tracking handler 22 * struct vb2_vmarea_handler - common vma refcount tracking handler.
23 * 23 *
24 * @refcount: pointer to refcount entry in the buffer 24 * @refcount: pointer to &refcount_t entry in the buffer.
25 * @put: callback to function that decreases buffer refcount 25 * @put: callback to function that decreases buffer refcount.
26 * @arg: argument for @put callback 26 * @arg: argument for @put callback.
27 */ 27 */
28struct vb2_vmarea_handler { 28struct vb2_vmarea_handler {
29 refcount_t *refcount; 29 refcount_t *refcount;
diff --git a/include/media/videobuf2-v4l2.h b/include/media/videobuf2-v4l2.h
index c2fa55657440..3d5e2d739f05 100644
--- a/include/media/videobuf2-v4l2.h
+++ b/include/media/videobuf2-v4l2.h
@@ -24,16 +24,17 @@
24#endif 24#endif
25 25
26/** 26/**
27 * struct vb2_v4l2_buffer - video buffer information for v4l2 27 * struct vb2_v4l2_buffer - video buffer information for v4l2.
28 * 28 *
29 * @vb2_buf: video buffer 2 29 * @vb2_buf: embedded struct &vb2_buffer.
30 * @flags: buffer informational flags 30 * @flags: buffer informational flags.
31 * @field: enum v4l2_field; field order of the image in the buffer 31 * @field: field order of the image in the buffer, as defined by
32 * @timecode: frame timecode 32 * &enum v4l2_field.
33 * @sequence: sequence count of this frame 33 * @timecode: frame timecode.
34 * @sequence: sequence count of this frame.
34 * 35 *
35 * Should contain enough information to be able to cover all the fields 36 * Should contain enough information to be able to cover all the fields
36 * of struct v4l2_buffer at videodev2.h 37 * of &struct v4l2_buffer at ``videodev2.h``.
37 */ 38 */
38struct vb2_v4l2_buffer { 39struct vb2_v4l2_buffer {
39 struct vb2_buffer vb2_buf; 40 struct vb2_buffer vb2_buf;
@@ -56,9 +57,9 @@ int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer *b);
56 * vb2_reqbufs() - Wrapper for vb2_core_reqbufs() that also verifies 57 * vb2_reqbufs() - Wrapper for vb2_core_reqbufs() that also verifies
57 * the memory and type values. 58 * the memory and type values.
58 * 59 *
59 * @q: videobuf2 queue 60 * @q: pointer to &struct vb2_queue with videobuf2 queue.
60 * @req: struct passed from userspace to vidioc_reqbufs handler 61 * @req: &struct v4l2_requestbuffers passed from userspace to
61 * in driver 62 * &v4l2_ioctl_ops->vidioc_reqbufs handler in driver.
62 */ 63 */
63int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req); 64int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req);
64 65
@@ -66,94 +67,99 @@ int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req);
66 * vb2_create_bufs() - Wrapper for vb2_core_create_bufs() that also verifies 67 * vb2_create_bufs() - Wrapper for vb2_core_create_bufs() that also verifies
67 * the memory and type values. 68 * the memory and type values.
68 * 69 *
69 * @q: videobuf2 queue 70 * @q: pointer to &struct vb2_queue with videobuf2 queue.
70 * @create: creation parameters, passed from userspace to vidioc_create_bufs 71 * @create: creation parameters, passed from userspace to
71 * handler in driver 72 * &v4l2_ioctl_ops->vidioc_create_bufs handler in driver
72 */ 73 */
73int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create); 74int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create);
74 75
75/** 76/**
76 * vb2_prepare_buf() - Pass ownership of a buffer from userspace to the kernel 77 * vb2_prepare_buf() - Pass ownership of a buffer from userspace to the kernel
77 * 78 *
78 * @q: videobuf2 queue 79 * @q: pointer to &struct vb2_queue with videobuf2 queue.
79 * @b: buffer structure passed from userspace to vidioc_prepare_buf 80 * @b: buffer structure passed from userspace to
80 * handler in driver 81 * &v4l2_ioctl_ops->vidioc_prepare_buf handler in driver
82 *
83 * Should be called from &v4l2_ioctl_ops->vidioc_prepare_buf ioctl handler
84 * of a driver.
81 * 85 *
82 * Should be called from vidioc_prepare_buf ioctl handler of a driver.
83 * This function: 86 * This function:
84 * 87 *
85 * #) verifies the passed buffer, 88 * #) verifies the passed buffer,
86 * #) calls buf_prepare callback in the driver (if provided), in which 89 * #) calls &vb2_ops->buf_prepare callback in the driver (if provided),
87 * driver-specific buffer initialization can be performed. 90 * in which driver-specific buffer initialization can be performed.
88 * 91 *
89 * The return values from this function are intended to be directly returned 92 * The return values from this function are intended to be directly returned
90 * from vidioc_prepare_buf handler in driver. 93 * from &v4l2_ioctl_ops->vidioc_prepare_buf handler in driver.
91 */ 94 */
92int vb2_prepare_buf(struct vb2_queue *q, struct v4l2_buffer *b); 95int vb2_prepare_buf(struct vb2_queue *q, struct v4l2_buffer *b);
93 96
94/** 97/**
95 * vb2_qbuf() - Queue a buffer from userspace 98 * vb2_qbuf() - Queue a buffer from userspace
96 * @q: videobuf2 queue 99 * @q: pointer to &struct vb2_queue with videobuf2 queue.
97 * @b: buffer structure passed from userspace to VIDIOC_QBUF() handler 100 * @b: buffer structure passed from userspace to
98 * in driver 101 * &v4l2_ioctl_ops->vidioc_qbuf handler in driver
99 * 102 *
100 * Should be called from VIDIOC_QBUF() ioctl handler of a driver. 103 * Should be called from &v4l2_ioctl_ops->vidioc_qbuf handler of a driver.
101 * 104 *
102 * This function: 105 * This function:
103 * 106 *
104 * #) verifies the passed buffer, 107 * #) verifies the passed buffer;
105 * #) if necessary, calls buf_prepare callback in the driver (if provided), in 108 * #) if necessary, calls &vb2_ops->buf_prepare callback in the driver
106 * which driver-specific buffer initialization can be performed, 109 * (if provided), in which driver-specific buffer initialization can
107 * #) if streaming is on, queues the buffer in driver by the means of buf_queue 110 * be performed;
108 * callback for processing. 111 * #) if streaming is on, queues the buffer in driver by the means of
112 * &vb2_ops->buf_queue callback for processing.
109 * 113 *
110 * The return values from this function are intended to be directly returned 114 * The return values from this function are intended to be directly returned
111 * from VIDIOC_QBUF() handler in driver. 115 * from &v4l2_ioctl_ops->vidioc_qbuf handler in driver.
112 */ 116 */
113int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b); 117int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b);
114 118
115/** 119/**
116 * vb2_expbuf() - Export a buffer as a file descriptor 120 * vb2_expbuf() - Export a buffer as a file descriptor
117 * @q: videobuf2 queue 121 * @q: pointer to &struct vb2_queue with videobuf2 queue.
118 * @eb: export buffer structure passed from userspace to VIDIOC_EXPBUF() 122 * @eb: export buffer structure passed from userspace to
119 * handler in driver 123 * &v4l2_ioctl_ops->vidioc_expbuf handler in driver
120 * 124 *
121 * The return values from this function are intended to be directly returned 125 * The return values from this function are intended to be directly returned
122 * from VIDIOC_EXPBUF() handler in driver. 126 * from &v4l2_ioctl_ops->vidioc_expbuf handler in driver.
123 */ 127 */
124int vb2_expbuf(struct vb2_queue *q, struct v4l2_exportbuffer *eb); 128int vb2_expbuf(struct vb2_queue *q, struct v4l2_exportbuffer *eb);
125 129
126/** 130/**
127 * vb2_dqbuf() - Dequeue a buffer to the userspace 131 * vb2_dqbuf() - Dequeue a buffer to the userspace
128 * @q: videobuf2 queue 132 * @q: pointer to &struct vb2_queue with videobuf2 queue.
129 * @b: buffer structure passed from userspace to VIDIOC_DQBUF() handler 133 * @b: buffer structure passed from userspace to
130 * in driver 134 * &v4l2_ioctl_ops->vidioc_dqbuf handler in driver
131 * @nonblocking: if true, this call will not sleep waiting for a buffer if no 135 * @nonblocking: if true, this call will not sleep waiting for a buffer if no
132 * buffers ready for dequeuing are present. Normally the driver 136 * buffers ready for dequeuing are present. Normally the driver
133 * would be passing (file->f_flags & O_NONBLOCK) here 137 * would be passing (&file->f_flags & %O_NONBLOCK) here
134 * 138 *
135 * Should be called from VIDIOC_DQBUF() ioctl handler of a driver. 139 * Should be called from &v4l2_ioctl_ops->vidioc_dqbuf ioctl handler
140 * of a driver.
136 * 141 *
137 * This function: 142 * This function:
138 * 143 *
139 * #) verifies the passed buffer, 144 * #) verifies the passed buffer;
140 * #) calls buf_finish callback in the driver (if provided), in which 145 * #) calls &vb2_ops->buf_finish callback in the driver (if provided), in which
141 * driver can perform any additional operations that may be required before 146 * driver can perform any additional operations that may be required before
142 * returning the buffer to userspace, such as cache sync, 147 * returning the buffer to userspace, such as cache sync;
143 * #) the buffer struct members are filled with relevant information for 148 * #) the buffer struct members are filled with relevant information for
144 * the userspace. 149 * the userspace.
145 * 150 *
146 * The return values from this function are intended to be directly returned 151 * The return values from this function are intended to be directly returned
147 * from VIDIOC_DQBUF() handler in driver. 152 * from &v4l2_ioctl_ops->vidioc_dqbuf handler in driver.
148 */ 153 */
149int vb2_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool nonblocking); 154int vb2_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool nonblocking);
150 155
151/** 156/**
152 * vb2_streamon - start streaming 157 * vb2_streamon - start streaming
153 * @q: videobuf2 queue 158 * @q: pointer to &struct vb2_queue with videobuf2 queue.
154 * @type: type argument passed from userspace to vidioc_streamon handler 159 * @type: type argument passed from userspace to vidioc_streamon handler,
160 * as defined by &enum v4l2_buf_type.
155 * 161 *
156 * Should be called from vidioc_streamon handler of a driver. 162 * Should be called from &v4l2_ioctl_ops->vidioc_streamon handler of a driver.
157 * 163 *
158 * This function: 164 * This function:
159 * 165 *
@@ -161,13 +167,13 @@ int vb2_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool nonblocking);
161 * 2) passes any previously queued buffers to the driver and starts streaming 167 * 2) passes any previously queued buffers to the driver and starts streaming
162 * 168 *
163 * The return values from this function are intended to be directly returned 169 * The return values from this function are intended to be directly returned
164 * from vidioc_streamon handler in the driver. 170 * from &v4l2_ioctl_ops->vidioc_streamon handler in the driver.
165 */ 171 */
166int vb2_streamon(struct vb2_queue *q, enum v4l2_buf_type type); 172int vb2_streamon(struct vb2_queue *q, enum v4l2_buf_type type);
167 173
168/** 174/**
169 * vb2_streamoff - stop streaming 175 * vb2_streamoff - stop streaming
170 * @q: videobuf2 queue 176 * @q: pointer to &struct vb2_queue with videobuf2 queue.
171 * @type: type argument passed from userspace to vidioc_streamoff handler 177 * @type: type argument passed from userspace to vidioc_streamoff handler
172 * 178 *
173 * Should be called from vidioc_streamoff handler of a driver. 179 * Should be called from vidioc_streamoff handler of a driver.
@@ -186,7 +192,7 @@ int vb2_streamoff(struct vb2_queue *q, enum v4l2_buf_type type);
186 192
187/** 193/**
188 * vb2_queue_init() - initialize a videobuf2 queue 194 * vb2_queue_init() - initialize a videobuf2 queue
189 * @q: videobuf2 queue; this structure should be allocated in driver 195 * @q: pointer to &struct vb2_queue with videobuf2 queue.
190 * 196 *
191 * The vb2_queue structure should be allocated by the driver. The driver is 197 * The vb2_queue structure should be allocated by the driver. The driver is
192 * responsible of clearing it's content and setting initial values for some 198 * responsible of clearing it's content and setting initial values for some
@@ -199,7 +205,7 @@ int __must_check vb2_queue_init(struct vb2_queue *q);
199 205
200/** 206/**
201 * vb2_queue_release() - stop streaming, release the queue and free memory 207 * vb2_queue_release() - stop streaming, release the queue and free memory
202 * @q: videobuf2 queue 208 * @q: pointer to &struct vb2_queue with videobuf2 queue.
203 * 209 *
204 * This function stops streaming and performs necessary clean ups, including 210 * This function stops streaming and performs necessary clean ups, including
205 * freeing video buffer memory. The driver is responsible for freeing 211 * freeing video buffer memory. The driver is responsible for freeing
@@ -209,7 +215,7 @@ void vb2_queue_release(struct vb2_queue *q);
209 215
210/** 216/**
211 * vb2_poll() - implements poll userspace operation 217 * vb2_poll() - implements poll userspace operation
212 * @q: videobuf2 queue 218 * @q: pointer to &struct vb2_queue with videobuf2 queue.
213 * @file: file argument passed to the poll file operation handler 219 * @file: file argument passed to the poll file operation handler
214 * @wait: wait argument passed to the poll file operation handler 220 * @wait: wait argument passed to the poll file operation handler
215 * 221 *
@@ -270,7 +276,7 @@ unsigned long vb2_fop_get_unmapped_area(struct file *file, unsigned long addr,
270/** 276/**
271 * vb2_ops_wait_prepare - helper function to lock a struct &vb2_queue 277 * vb2_ops_wait_prepare - helper function to lock a struct &vb2_queue
272 * 278 *
273 * @vq: pointer to struct vb2_queue 279 * @vq: pointer to &struct vb2_queue
274 * 280 *
275 * ..note:: only use if vq->lock is non-NULL. 281 * ..note:: only use if vq->lock is non-NULL.
276 */ 282 */
@@ -279,7 +285,7 @@ void vb2_ops_wait_prepare(struct vb2_queue *vq);
279/** 285/**
280 * vb2_ops_wait_finish - helper function to unlock a struct &vb2_queue 286 * vb2_ops_wait_finish - helper function to unlock a struct &vb2_queue
281 * 287 *
282 * @vq: pointer to struct vb2_queue 288 * @vq: pointer to &struct vb2_queue
283 * 289 *
284 * ..note:: only use if vq->lock is non-NULL. 290 * ..note:: only use if vq->lock is non-NULL.
285 */ 291 */
diff --git a/include/rdma/ib_hdrs.h b/include/rdma/ib_hdrs.h
index c124d515f7d5..6e35416170a3 100644
--- a/include/rdma/ib_hdrs.h
+++ b/include/rdma/ib_hdrs.h
@@ -313,16 +313,14 @@ static inline u32 ib_bth_get_qpn(struct ib_other_headers *ohdr)
313 return (u32)((be32_to_cpu(ohdr->bth[1])) & IB_QPN_MASK); 313 return (u32)((be32_to_cpu(ohdr->bth[1])) & IB_QPN_MASK);
314} 314}
315 315
316static inline u8 ib_bth_get_becn(struct ib_other_headers *ohdr) 316static inline bool ib_bth_get_becn(struct ib_other_headers *ohdr)
317{ 317{
318 return (u8)((be32_to_cpu(ohdr->bth[1]) >> IB_BECN_SHIFT) & 318 return (ohdr->bth[1]) & cpu_to_be32(IB_BECN_SMASK);
319 IB_BECN_MASK);
320} 319}
321 320
322static inline u8 ib_bth_get_fecn(struct ib_other_headers *ohdr) 321static inline bool ib_bth_get_fecn(struct ib_other_headers *ohdr)
323{ 322{
324 return (u8)((be32_to_cpu(ohdr->bth[1]) >> IB_FECN_SHIFT) & 323 return (ohdr->bth[1]) & cpu_to_be32(IB_FECN_SMASK);
325 IB_FECN_MASK);
326} 324}
327 325
328static inline u8 ib_bth_get_tver(struct ib_other_headers *ohdr) 326static inline u8 ib_bth_get_tver(struct ib_other_headers *ohdr)
@@ -331,4 +329,13 @@ static inline u8 ib_bth_get_tver(struct ib_other_headers *ohdr)
331 IB_BTH_TVER_MASK); 329 IB_BTH_TVER_MASK);
332} 330}
333 331
332static inline bool ib_bth_is_solicited(struct ib_other_headers *ohdr)
333{
334 return ohdr->bth[0] & cpu_to_be32(IB_BTH_SOLICITED);
335}
336
337static inline bool ib_bth_is_migration(struct ib_other_headers *ohdr)
338{
339 return ohdr->bth[0] & cpu_to_be32(IB_BTH_MIG_REQ);
340}
334#endif /* IB_HDRS_H */ 341#endif /* IB_HDRS_H */
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 5263c86fd103..73b2387e3f74 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -874,6 +874,7 @@ struct ib_mr_status {
874__attribute_const__ enum ib_rate mult_to_ib_rate(int mult); 874__attribute_const__ enum ib_rate mult_to_ib_rate(int mult);
875 875
876enum rdma_ah_attr_type { 876enum rdma_ah_attr_type {
877 RDMA_AH_ATTR_TYPE_UNDEFINED,
877 RDMA_AH_ATTR_TYPE_IB, 878 RDMA_AH_ATTR_TYPE_IB,
878 RDMA_AH_ATTR_TYPE_ROCE, 879 RDMA_AH_ATTR_TYPE_ROCE,
879 RDMA_AH_ATTR_TYPE_OPA, 880 RDMA_AH_ATTR_TYPE_OPA,
@@ -3810,17 +3811,24 @@ static inline void rdma_ah_set_grh(struct rdma_ah_attr *attr,
3810 grh->traffic_class = traffic_class; 3811 grh->traffic_class = traffic_class;
3811} 3812}
3812 3813
3813/*Get AH type */ 3814/**
3815 * rdma_ah_find_type - Return address handle type.
3816 *
3817 * @dev: Device to be checked
3818 * @port_num: Port number
3819 */
3814static inline enum rdma_ah_attr_type rdma_ah_find_type(struct ib_device *dev, 3820static inline enum rdma_ah_attr_type rdma_ah_find_type(struct ib_device *dev,
3815 u32 port_num) 3821 u8 port_num)
3816{ 3822{
3817 if (rdma_protocol_roce(dev, port_num)) 3823 if (rdma_protocol_roce(dev, port_num))
3818 return RDMA_AH_ATTR_TYPE_ROCE; 3824 return RDMA_AH_ATTR_TYPE_ROCE;
3819 else if ((rdma_protocol_ib(dev, port_num)) && 3825 if (rdma_protocol_ib(dev, port_num)) {
3820 (rdma_cap_opa_ah(dev, port_num))) 3826 if (rdma_cap_opa_ah(dev, port_num))
3821 return RDMA_AH_ATTR_TYPE_OPA; 3827 return RDMA_AH_ATTR_TYPE_OPA;
3822 else
3823 return RDMA_AH_ATTR_TYPE_IB; 3828 return RDMA_AH_ATTR_TYPE_IB;
3829 }
3830
3831 return RDMA_AH_ATTR_TYPE_UNDEFINED;
3824} 3832}
3825 3833
3826/** 3834/**
diff --git a/include/uapi/linux/dvb/dmx.h b/include/uapi/linux/dvb/dmx.h
index c10f1324b4ca..5f3c5a918f00 100644
--- a/include/uapi/linux/dvb/dmx.h
+++ b/include/uapi/linux/dvb/dmx.h
@@ -211,6 +211,61 @@ struct dmx_stc {
211 __u64 stc; 211 __u64 stc;
212}; 212};
213 213
214/**
215 * struct dmx_buffer - dmx buffer info
216 *
217 * @index: id number of the buffer
218 * @bytesused: number of bytes occupied by data in the buffer (payload);
219 * @offset: for buffers with memory == DMX_MEMORY_MMAP;
220 * offset from the start of the device memory for this plane,
221 * (or a "cookie" that should be passed to mmap() as offset)
222 * @length: size in bytes of the buffer
223 *
224 * Contains data exchanged by application and driver using one of the streaming
225 * I/O methods.
226 */
227struct dmx_buffer {
228 __u32 index;
229 __u32 bytesused;
230 __u32 offset;
231 __u32 length;
232};
233
234/**
235 * struct dmx_requestbuffers - request dmx buffer information
236 *
237 * @count: number of requested buffers,
238 * @size: size in bytes of the requested buffer
239 *
240 * Contains data used for requesting a dmx buffer.
241 * All reserved fields must be set to zero.
242 */
243struct dmx_requestbuffers {
244 __u32 count;
245 __u32 size;
246};
247
248/**
249 * struct dmx_exportbuffer - export of dmx buffer as DMABUF file descriptor
250 *
251 * @index: id number of the buffer
252 * @flags: flags for newly created file, currently only O_CLOEXEC is
253 * supported, refer to manual of open syscall for more details
254 * @fd: file descriptor associated with DMABUF (set by driver)
255 *
256 * Contains data used for exporting a dmx buffer as DMABUF file descriptor.
257 * The buffer is identified by a 'cookie' returned by DMX_QUERYBUF
258 * (identical to the cookie used to mmap() the buffer to userspace). All
259 * reserved fields must be set to zero. The field reserved0 is expected to
260 * become a structure 'type' allowing an alternative layout of the structure
261 * content. Therefore this field should not be used for any other extensions.
262 */
263struct dmx_exportbuffer {
264 __u32 index;
265 __u32 flags;
266 __s32 fd;
267};
268
214#define DMX_START _IO('o', 41) 269#define DMX_START _IO('o', 41)
215#define DMX_STOP _IO('o', 42) 270#define DMX_STOP _IO('o', 42)
216#define DMX_SET_FILTER _IOW('o', 43, struct dmx_sct_filter_params) 271#define DMX_SET_FILTER _IOW('o', 43, struct dmx_sct_filter_params)
@@ -231,4 +286,10 @@ typedef struct dmx_filter dmx_filter_t;
231 286
232#endif 287#endif
233 288
234#endif /* _UAPI_DVBDMX_H_ */ 289#define DMX_REQBUFS _IOWR('o', 60, struct dmx_requestbuffers)
290#define DMX_QUERYBUF _IOWR('o', 61, struct dmx_buffer)
291#define DMX_EXPBUF _IOWR('o', 62, struct dmx_exportbuffer)
292#define DMX_QBUF _IOWR('o', 63, struct dmx_buffer)
293#define DMX_DQBUF _IOWR('o', 64, struct dmx_buffer)
294
295#endif /* _DVBDMX_H_ */
diff --git a/include/uapi/linux/dvb/frontend.h b/include/uapi/linux/dvb/frontend.h
index b297b65845d6..4f9b4551c534 100644
--- a/include/uapi/linux/dvb/frontend.h
+++ b/include/uapi/linux/dvb/frontend.h
@@ -547,7 +547,10 @@ enum fe_interleaving {
547#define DTV_STAT_ERROR_BLOCK_COUNT 68 547#define DTV_STAT_ERROR_BLOCK_COUNT 68
548#define DTV_STAT_TOTAL_BLOCK_COUNT 69 548#define DTV_STAT_TOTAL_BLOCK_COUNT 69
549 549
550#define DTV_MAX_COMMAND DTV_STAT_TOTAL_BLOCK_COUNT 550/* Physical layer scrambling */
551#define DTV_SCRAMBLING_SEQUENCE_INDEX 70
552
553#define DTV_MAX_COMMAND DTV_SCRAMBLING_SEQUENCE_INDEX
551 554
552/** 555/**
553 * enum fe_pilot - Type of pilot tone 556 * enum fe_pilot - Type of pilot tone
@@ -756,16 +759,15 @@ enum fecap_scale_params {
756/** 759/**
757 * struct dtv_stats - Used for reading a DTV status property 760 * struct dtv_stats - Used for reading a DTV status property
758 * 761 *
759 * @scale: Filled with enum fecap_scale_params - the scale 762 * @scale:
760 * in usage for that parameter 763 * Filled with enum fecap_scale_params - the scale in usage
761 * 764 * for that parameter
762 * The ``{unnamed_union}`` may have either one of the values below:
763 * 765 *
764 * %svalue 766 * @svalue:
765 * integer value of the measure, for %FE_SCALE_DECIBEL, 767 * integer value of the measure, for %FE_SCALE_DECIBEL,
766 * used for dB measures. The unit is 0.001 dB. 768 * used for dB measures. The unit is 0.001 dB.
767 * 769 *
768 * %uvalue 770 * @uvalue:
769 * unsigned integer value of the measure, used when @scale is 771 * unsigned integer value of the measure, used when @scale is
770 * either %FE_SCALE_RELATIVE or %FE_SCALE_COUNTER. 772 * either %FE_SCALE_RELATIVE or %FE_SCALE_COUNTER.
771 * 773 *
@@ -828,19 +830,19 @@ struct dtv_fe_stats {
828/** 830/**
829 * struct dtv_property - store one of frontend command and its value 831 * struct dtv_property - store one of frontend command and its value
830 * 832 *
831 * @cmd: Digital TV command. 833 * @cmd: Digital TV command.
832 * @reserved: Not used. 834 * @reserved: Not used.
833 * @u: Union with the values for the command. 835 * @u: Union with the values for the command.
834 * @result: Unused 836 * @u.data: A unsigned 32 bits integer with command value.
835 * 837 * @u.buffer: Struct to store bigger properties.
836 * The @u union may have either one of the values below: 838 * Currently unused.
839 * @u.buffer.data: an unsigned 32-bits array.
840 * @u.buffer.len: number of elements of the buffer.
841 * @u.buffer.reserved1: Reserved.
842 * @u.buffer.reserved2: Reserved.
843 * @u.st: a &struct dtv_fe_stats array of statistics.
844 * @result: Currently unused.
837 * 845 *
838 * %data
839 * an unsigned 32-bits number.
840 * %st
841 * a &struct dtv_fe_stats array of statistics.
842 * %buffer
843 * a buffer of up to 32 characters (currently unused).
844 */ 846 */
845struct dtv_property { 847struct dtv_property {
846 __u32 cmd; 848 __u32 cmd;
diff --git a/include/uapi/linux/dvb/version.h b/include/uapi/linux/dvb/version.h
index 02e32ea83984..2c5cffe6d2a0 100644
--- a/include/uapi/linux/dvb/version.h
+++ b/include/uapi/linux/dvb/version.h
@@ -25,6 +25,6 @@
25#define _DVBVERSION_H_ 25#define _DVBVERSION_H_
26 26
27#define DVB_API_VERSION 5 27#define DVB_API_VERSION 5
28#define DVB_API_VERSION_MINOR 10 28#define DVB_API_VERSION_MINOR 11
29 29
30#endif /*_DVBVERSION_H_*/ 30#endif /*_DVBVERSION_H_*/
diff --git a/include/uapi/linux/dvb/video.h b/include/uapi/linux/dvb/video.h
index 4d51f98182bb..df3d7028c807 100644
--- a/include/uapi/linux/dvb/video.h
+++ b/include/uapi/linux/dvb/video.h
@@ -83,11 +83,11 @@ typedef enum {
83#define VIDEO_CMD_CONTINUE (3) 83#define VIDEO_CMD_CONTINUE (3)
84 84
85/* Flags for VIDEO_CMD_FREEZE */ 85/* Flags for VIDEO_CMD_FREEZE */
86#define VIDEO_CMD_FREEZE_TO_BLACK (1 << 0) 86#define VIDEO_CMD_FREEZE_TO_BLACK (1 << 0)
87 87
88/* Flags for VIDEO_CMD_STOP */ 88/* Flags for VIDEO_CMD_STOP */
89#define VIDEO_CMD_STOP_TO_BLACK (1 << 0) 89#define VIDEO_CMD_STOP_TO_BLACK (1 << 0)
90#define VIDEO_CMD_STOP_IMMEDIATELY (1 << 1) 90#define VIDEO_CMD_STOP_IMMEDIATELY (1 << 1)
91 91
92/* Play input formats: */ 92/* Play input formats: */
93/* The decoder has no special format requirements */ 93/* The decoder has no special format requirements */
@@ -124,8 +124,8 @@ struct video_command {
124/* FIELD_UNKNOWN can be used if the hardware does not know whether 124/* FIELD_UNKNOWN can be used if the hardware does not know whether
125 the Vsync is for an odd, even or progressive (i.e. non-interlaced) 125 the Vsync is for an odd, even or progressive (i.e. non-interlaced)
126 field. */ 126 field. */
127#define VIDEO_VSYNC_FIELD_UNKNOWN (0) 127#define VIDEO_VSYNC_FIELD_UNKNOWN (0)
128#define VIDEO_VSYNC_FIELD_ODD (1) 128#define VIDEO_VSYNC_FIELD_ODD (1)
129#define VIDEO_VSYNC_FIELD_EVEN (2) 129#define VIDEO_VSYNC_FIELD_EVEN (2)
130#define VIDEO_VSYNC_FIELD_PROGRESSIVE (3) 130#define VIDEO_VSYNC_FIELD_PROGRESSIVE (3)
131 131
@@ -133,8 +133,8 @@ struct video_event {
133 __s32 type; 133 __s32 type;
134#define VIDEO_EVENT_SIZE_CHANGED 1 134#define VIDEO_EVENT_SIZE_CHANGED 1
135#define VIDEO_EVENT_FRAME_RATE_CHANGED 2 135#define VIDEO_EVENT_FRAME_RATE_CHANGED 2
136#define VIDEO_EVENT_DECODER_STOPPED 3 136#define VIDEO_EVENT_DECODER_STOPPED 3
137#define VIDEO_EVENT_VSYNC 4 137#define VIDEO_EVENT_VSYNC 4
138 /* unused, make sure to use atomic time for y2038 if it ever gets used */ 138 /* unused, make sure to use atomic time for y2038 if it ever gets used */
139 long timestamp; 139 long timestamp;
140 union { 140 union {
@@ -268,9 +268,9 @@ typedef __u16 video_attributes_t;
268#define VIDEO_GET_PTS _IOR('o', 57, __u64) 268#define VIDEO_GET_PTS _IOR('o', 57, __u64)
269 269
270/* Read the number of displayed frames since the decoder was started */ 270/* Read the number of displayed frames since the decoder was started */
271#define VIDEO_GET_FRAME_COUNT _IOR('o', 58, __u64) 271#define VIDEO_GET_FRAME_COUNT _IOR('o', 58, __u64)
272 272
273#define VIDEO_COMMAND _IOWR('o', 59, struct video_command) 273#define VIDEO_COMMAND _IOWR('o', 59, struct video_command)
274#define VIDEO_TRY_COMMAND _IOWR('o', 60, struct video_command) 274#define VIDEO_TRY_COMMAND _IOWR('o', 60, struct video_command)
275 275
276#endif /* _UAPI_DVBVIDEO_H_ */ 276#endif /* _UAPI_DVBVIDEO_H_ */
diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
index 061fa62958a2..53fbae27b280 100644
--- a/include/uapi/linux/input-event-codes.h
+++ b/include/uapi/linux/input-event-codes.h
@@ -594,6 +594,7 @@
594#define BTN_DPAD_RIGHT 0x223 594#define BTN_DPAD_RIGHT 0x223
595 595
596#define KEY_ALS_TOGGLE 0x230 /* Ambient light sensor */ 596#define KEY_ALS_TOGGLE 0x230 /* Ambient light sensor */
597#define KEY_ROTATE_LOCK_TOGGLE 0x231 /* Display rotation lock */
597 598
598#define KEY_BUTTONCONFIG 0x240 /* AL Button Configuration */ 599#define KEY_BUTTONCONFIG 0x240 /* AL Button Configuration */
599#define KEY_TASKMANAGER 0x241 /* AL Task/Project Manager */ 600#define KEY_TASKMANAGER 0x241 /* AL Task/Project Manager */
diff --git a/include/uapi/linux/lirc.h b/include/uapi/linux/lirc.h
index c3aef4316fbf..4fe580d36e41 100644
--- a/include/uapi/linux/lirc.h
+++ b/include/uapi/linux/lirc.h
@@ -47,12 +47,14 @@
47#define LIRC_MODE_RAW 0x00000001 47#define LIRC_MODE_RAW 0x00000001
48#define LIRC_MODE_PULSE 0x00000002 48#define LIRC_MODE_PULSE 0x00000002
49#define LIRC_MODE_MODE2 0x00000004 49#define LIRC_MODE_MODE2 0x00000004
50#define LIRC_MODE_SCANCODE 0x00000008
50#define LIRC_MODE_LIRCCODE 0x00000010 51#define LIRC_MODE_LIRCCODE 0x00000010
51 52
52 53
53#define LIRC_CAN_SEND_RAW LIRC_MODE2SEND(LIRC_MODE_RAW) 54#define LIRC_CAN_SEND_RAW LIRC_MODE2SEND(LIRC_MODE_RAW)
54#define LIRC_CAN_SEND_PULSE LIRC_MODE2SEND(LIRC_MODE_PULSE) 55#define LIRC_CAN_SEND_PULSE LIRC_MODE2SEND(LIRC_MODE_PULSE)
55#define LIRC_CAN_SEND_MODE2 LIRC_MODE2SEND(LIRC_MODE_MODE2) 56#define LIRC_CAN_SEND_MODE2 LIRC_MODE2SEND(LIRC_MODE_MODE2)
57#define LIRC_CAN_SEND_SCANCODE LIRC_MODE2SEND(LIRC_MODE_SCANCODE)
56#define LIRC_CAN_SEND_LIRCCODE LIRC_MODE2SEND(LIRC_MODE_LIRCCODE) 58#define LIRC_CAN_SEND_LIRCCODE LIRC_MODE2SEND(LIRC_MODE_LIRCCODE)
57 59
58#define LIRC_CAN_SEND_MASK 0x0000003f 60#define LIRC_CAN_SEND_MASK 0x0000003f
@@ -64,6 +66,7 @@
64#define LIRC_CAN_REC_RAW LIRC_MODE2REC(LIRC_MODE_RAW) 66#define LIRC_CAN_REC_RAW LIRC_MODE2REC(LIRC_MODE_RAW)
65#define LIRC_CAN_REC_PULSE LIRC_MODE2REC(LIRC_MODE_PULSE) 67#define LIRC_CAN_REC_PULSE LIRC_MODE2REC(LIRC_MODE_PULSE)
66#define LIRC_CAN_REC_MODE2 LIRC_MODE2REC(LIRC_MODE_MODE2) 68#define LIRC_CAN_REC_MODE2 LIRC_MODE2REC(LIRC_MODE_MODE2)
69#define LIRC_CAN_REC_SCANCODE LIRC_MODE2REC(LIRC_MODE_SCANCODE)
67#define LIRC_CAN_REC_LIRCCODE LIRC_MODE2REC(LIRC_MODE_LIRCCODE) 70#define LIRC_CAN_REC_LIRCCODE LIRC_MODE2REC(LIRC_MODE_LIRCCODE)
68 71
69#define LIRC_CAN_REC_MASK LIRC_MODE2REC(LIRC_CAN_SEND_MASK) 72#define LIRC_CAN_REC_MASK LIRC_MODE2REC(LIRC_CAN_SEND_MASK)
@@ -131,4 +134,83 @@
131 134
132#define LIRC_SET_WIDEBAND_RECEIVER _IOW('i', 0x00000023, __u32) 135#define LIRC_SET_WIDEBAND_RECEIVER _IOW('i', 0x00000023, __u32)
133 136
137/*
138 * struct lirc_scancode - decoded scancode with protocol for use with
139 * LIRC_MODE_SCANCODE
140 *
141 * @timestamp: Timestamp in nanoseconds using CLOCK_MONOTONIC when IR
142 * was decoded.
143 * @flags: should be 0 for transmit. When receiving scancodes,
144 * LIRC_SCANCODE_FLAG_TOGGLE or LIRC_SCANCODE_FLAG_REPEAT can be set
145 * depending on the protocol
146 * @rc_proto: see enum rc_proto
147 * @keycode: the translated keycode. Set to 0 for transmit.
148 * @scancode: the scancode received or to be sent
149 */
150struct lirc_scancode {
151 __u64 timestamp;
152 __u16 flags;
153 __u16 rc_proto;
154 __u32 keycode;
155 __u64 scancode;
156};
157
158/* Set if the toggle bit of rc-5 or rc-6 is enabled */
159#define LIRC_SCANCODE_FLAG_TOGGLE 1
160/* Set if this is a nec or sanyo repeat */
161#define LIRC_SCANCODE_FLAG_REPEAT 2
162
163/**
164 * enum rc_proto - the Remote Controller protocol
165 *
166 * @RC_PROTO_UNKNOWN: Protocol not known
167 * @RC_PROTO_OTHER: Protocol known but proprietary
168 * @RC_PROTO_RC5: Philips RC5 protocol
169 * @RC_PROTO_RC5X_20: Philips RC5x 20 bit protocol
170 * @RC_PROTO_RC5_SZ: StreamZap variant of RC5
171 * @RC_PROTO_JVC: JVC protocol
172 * @RC_PROTO_SONY12: Sony 12 bit protocol
173 * @RC_PROTO_SONY15: Sony 15 bit protocol
174 * @RC_PROTO_SONY20: Sony 20 bit protocol
175 * @RC_PROTO_NEC: NEC protocol
176 * @RC_PROTO_NECX: Extended NEC protocol
177 * @RC_PROTO_NEC32: NEC 32 bit protocol
178 * @RC_PROTO_SANYO: Sanyo protocol
179 * @RC_PROTO_MCIR2_KBD: RC6-ish MCE keyboard
180 * @RC_PROTO_MCIR2_MSE: RC6-ish MCE mouse
181 * @RC_PROTO_RC6_0: Philips RC6-0-16 protocol
182 * @RC_PROTO_RC6_6A_20: Philips RC6-6A-20 protocol
183 * @RC_PROTO_RC6_6A_24: Philips RC6-6A-24 protocol
184 * @RC_PROTO_RC6_6A_32: Philips RC6-6A-32 protocol
185 * @RC_PROTO_RC6_MCE: MCE (Philips RC6-6A-32 subtype) protocol
186 * @RC_PROTO_SHARP: Sharp protocol
187 * @RC_PROTO_XMP: XMP protocol
188 * @RC_PROTO_CEC: CEC protocol
189 */
190enum rc_proto {
191 RC_PROTO_UNKNOWN = 0,
192 RC_PROTO_OTHER = 1,
193 RC_PROTO_RC5 = 2,
194 RC_PROTO_RC5X_20 = 3,
195 RC_PROTO_RC5_SZ = 4,
196 RC_PROTO_JVC = 5,
197 RC_PROTO_SONY12 = 6,
198 RC_PROTO_SONY15 = 7,
199 RC_PROTO_SONY20 = 8,
200 RC_PROTO_NEC = 9,
201 RC_PROTO_NECX = 10,
202 RC_PROTO_NEC32 = 11,
203 RC_PROTO_SANYO = 12,
204 RC_PROTO_MCIR2_KBD = 13,
205 RC_PROTO_MCIR2_MSE = 14,
206 RC_PROTO_RC6_0 = 15,
207 RC_PROTO_RC6_6A_20 = 16,
208 RC_PROTO_RC6_6A_24 = 17,
209 RC_PROTO_RC6_6A_32 = 18,
210 RC_PROTO_RC6_MCE = 19,
211 RC_PROTO_SHARP = 20,
212 RC_PROTO_XMP = 21,
213 RC_PROTO_CEC = 22,
214};
215
134#endif 216#endif
diff --git a/include/uapi/linux/ndctl.h b/include/uapi/linux/ndctl.h
index 3f03567631cb..7e27070b9440 100644
--- a/include/uapi/linux/ndctl.h
+++ b/include/uapi/linux/ndctl.h
@@ -15,54 +15,6 @@
15 15
16#include <linux/types.h> 16#include <linux/types.h>
17 17
18struct nd_cmd_smart {
19 __u32 status;
20 __u8 data[128];
21} __packed;
22
23#define ND_SMART_HEALTH_VALID (1 << 0)
24#define ND_SMART_SPARES_VALID (1 << 1)
25#define ND_SMART_USED_VALID (1 << 2)
26#define ND_SMART_TEMP_VALID (1 << 3)
27#define ND_SMART_CTEMP_VALID (1 << 4)
28#define ND_SMART_ALARM_VALID (1 << 9)
29#define ND_SMART_SHUTDOWN_VALID (1 << 10)
30#define ND_SMART_VENDOR_VALID (1 << 11)
31#define ND_SMART_SPARE_TRIP (1 << 0)
32#define ND_SMART_TEMP_TRIP (1 << 1)
33#define ND_SMART_CTEMP_TRIP (1 << 2)
34#define ND_SMART_NON_CRITICAL_HEALTH (1 << 0)
35#define ND_SMART_CRITICAL_HEALTH (1 << 1)
36#define ND_SMART_FATAL_HEALTH (1 << 2)
37
38struct nd_smart_payload {
39 __u32 flags;
40 __u8 reserved0[4];
41 __u8 health;
42 __u8 spares;
43 __u8 life_used;
44 __u8 alarm_flags;
45 __u16 temperature;
46 __u16 ctrl_temperature;
47 __u8 reserved1[15];
48 __u8 shutdown_state;
49 __u32 vendor_size;
50 __u8 vendor_data[92];
51} __packed;
52
53struct nd_cmd_smart_threshold {
54 __u32 status;
55 __u8 data[8];
56} __packed;
57
58struct nd_smart_threshold_payload {
59 __u8 alarm_control;
60 __u8 reserved0;
61 __u16 temperature;
62 __u8 spares;
63 __u8 reserved[3];
64} __packed;
65
66struct nd_cmd_dimm_flags { 18struct nd_cmd_dimm_flags {
67 __u32 status; 19 __u32 status;
68 __u32 flags; 20 __u32 flags;
@@ -211,12 +163,6 @@ static inline const char *nvdimm_cmd_name(unsigned cmd)
211 163
212#define ND_IOCTL 'N' 164#define ND_IOCTL 'N'
213 165
214#define ND_IOCTL_SMART _IOWR(ND_IOCTL, ND_CMD_SMART,\
215 struct nd_cmd_smart)
216
217#define ND_IOCTL_SMART_THRESHOLD _IOWR(ND_IOCTL, ND_CMD_SMART_THRESHOLD,\
218 struct nd_cmd_smart_threshold)
219
220#define ND_IOCTL_DIMM_FLAGS _IOWR(ND_IOCTL, ND_CMD_DIMM_FLAGS,\ 166#define ND_IOCTL_DIMM_FLAGS _IOWR(ND_IOCTL, ND_CMD_DIMM_FLAGS,\
221 struct nd_cmd_dimm_flags) 167 struct nd_cmd_dimm_flags)
222 168
@@ -263,7 +209,7 @@ enum nd_driver_flags {
263}; 209};
264 210
265enum { 211enum {
266 ND_MIN_NAMESPACE_SIZE = 0x00400000, 212 ND_MIN_NAMESPACE_SIZE = PAGE_SIZE,
267}; 213};
268 214
269enum ars_masks { 215enum ars_masks {
diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h
index 70c2b2ade048..0c79eac5e9b8 100644
--- a/include/uapi/linux/pci_regs.h
+++ b/include/uapi/linux/pci_regs.h
@@ -622,15 +622,19 @@
622 * safely. 622 * safely.
623 */ 623 */
624#define PCI_EXP_DEVCAP2 36 /* Device Capabilities 2 */ 624#define PCI_EXP_DEVCAP2 36 /* Device Capabilities 2 */
625#define PCI_EXP_DEVCAP2_COMP_TMOUT_DIS 0x00000010 /* Completion Timeout Disable supported */
625#define PCI_EXP_DEVCAP2_ARI 0x00000020 /* Alternative Routing-ID */ 626#define PCI_EXP_DEVCAP2_ARI 0x00000020 /* Alternative Routing-ID */
626#define PCI_EXP_DEVCAP2_ATOMIC_ROUTE 0x00000040 /* Atomic Op routing */ 627#define PCI_EXP_DEVCAP2_ATOMIC_ROUTE 0x00000040 /* Atomic Op routing */
627#define PCI_EXP_DEVCAP2_ATOMIC_COMP64 0x00000100 /* Atomic 64-bit compare */ 628#define PCI_EXP_DEVCAP2_ATOMIC_COMP32 0x00000080 /* 32b AtomicOp completion */
629#define PCI_EXP_DEVCAP2_ATOMIC_COMP64 0x00000100 /* 64b AtomicOp completion */
630#define PCI_EXP_DEVCAP2_ATOMIC_COMP128 0x00000200 /* 128b AtomicOp completion */
628#define PCI_EXP_DEVCAP2_LTR 0x00000800 /* Latency tolerance reporting */ 631#define PCI_EXP_DEVCAP2_LTR 0x00000800 /* Latency tolerance reporting */
629#define PCI_EXP_DEVCAP2_OBFF_MASK 0x000c0000 /* OBFF support mechanism */ 632#define PCI_EXP_DEVCAP2_OBFF_MASK 0x000c0000 /* OBFF support mechanism */
630#define PCI_EXP_DEVCAP2_OBFF_MSG 0x00040000 /* New message signaling */ 633#define PCI_EXP_DEVCAP2_OBFF_MSG 0x00040000 /* New message signaling */
631#define PCI_EXP_DEVCAP2_OBFF_WAKE 0x00080000 /* Re-use WAKE# for OBFF */ 634#define PCI_EXP_DEVCAP2_OBFF_WAKE 0x00080000 /* Re-use WAKE# for OBFF */
632#define PCI_EXP_DEVCTL2 40 /* Device Control 2 */ 635#define PCI_EXP_DEVCTL2 40 /* Device Control 2 */
633#define PCI_EXP_DEVCTL2_COMP_TIMEOUT 0x000f /* Completion Timeout Value */ 636#define PCI_EXP_DEVCTL2_COMP_TIMEOUT 0x000f /* Completion Timeout Value */
637#define PCI_EXP_DEVCTL2_COMP_TMOUT_DIS 0x0010 /* Completion Timeout Disable */
634#define PCI_EXP_DEVCTL2_ARI 0x0020 /* Alternative Routing-ID */ 638#define PCI_EXP_DEVCTL2_ARI 0x0020 /* Alternative Routing-ID */
635#define PCI_EXP_DEVCTL2_ATOMIC_REQ 0x0040 /* Set Atomic requests */ 639#define PCI_EXP_DEVCTL2_ATOMIC_REQ 0x0040 /* Set Atomic requests */
636#define PCI_EXP_DEVCTL2_ATOMIC_EGRESS_BLOCK 0x0080 /* Block atomic egress */ 640#define PCI_EXP_DEVCTL2_ATOMIC_EGRESS_BLOCK 0x0080 /* Block atomic egress */
@@ -966,26 +970,28 @@
966 970
967/* Downstream Port Containment */ 971/* Downstream Port Containment */
968#define PCI_EXP_DPC_CAP 4 /* DPC Capability */ 972#define PCI_EXP_DPC_CAP 4 /* DPC Capability */
969#define PCI_EXP_DPC_IRQ 0x1f /* DPC Interrupt Message Number */ 973#define PCI_EXP_DPC_IRQ 0x001F /* Interrupt Message Number */
970#define PCI_EXP_DPC_CAP_RP_EXT 0x20 /* Root Port Extensions for DPC */ 974#define PCI_EXP_DPC_CAP_RP_EXT 0x0020 /* Root Port Extensions */
971#define PCI_EXP_DPC_CAP_POISONED_TLP 0x40 /* Poisoned TLP Egress Blocking Supported */ 975#define PCI_EXP_DPC_CAP_POISONED_TLP 0x0040 /* Poisoned TLP Egress Blocking Supported */
972#define PCI_EXP_DPC_CAP_SW_TRIGGER 0x80 /* Software Triggering Supported */ 976#define PCI_EXP_DPC_CAP_SW_TRIGGER 0x0080 /* Software Triggering Supported */
973#define PCI_EXP_DPC_RP_PIO_LOG_SIZE 0xF00 /* RP PIO log size */ 977#define PCI_EXP_DPC_RP_PIO_LOG_SIZE 0x0F00 /* RP PIO Log Size */
974#define PCI_EXP_DPC_CAP_DL_ACTIVE 0x1000 /* ERR_COR signal on DL_Active supported */ 978#define PCI_EXP_DPC_CAP_DL_ACTIVE 0x1000 /* ERR_COR signal on DL_Active supported */
975 979
976#define PCI_EXP_DPC_CTL 6 /* DPC control */ 980#define PCI_EXP_DPC_CTL 6 /* DPC control */
977#define PCI_EXP_DPC_CTL_EN_NONFATAL 0x02 /* Enable trigger on ERR_NONFATAL message */ 981#define PCI_EXP_DPC_CTL_EN_NONFATAL 0x0002 /* Enable trigger on ERR_NONFATAL message */
978#define PCI_EXP_DPC_CTL_INT_EN 0x08 /* DPC Interrupt Enable */ 982#define PCI_EXP_DPC_CTL_INT_EN 0x0008 /* DPC Interrupt Enable */
979 983
980#define PCI_EXP_DPC_STATUS 8 /* DPC Status */ 984#define PCI_EXP_DPC_STATUS 8 /* DPC Status */
981#define PCI_EXP_DPC_STATUS_TRIGGER 0x01 /* Trigger Status */ 985#define PCI_EXP_DPC_STATUS_TRIGGER 0x0001 /* Trigger Status */
982#define PCI_EXP_DPC_STATUS_INTERRUPT 0x08 /* Interrupt Status */ 986#define PCI_EXP_DPC_STATUS_TRIGGER_RSN 0x0006 /* Trigger Reason */
983#define PCI_EXP_DPC_RP_BUSY 0x10 /* Root Port Busy */ 987#define PCI_EXP_DPC_STATUS_INTERRUPT 0x0008 /* Interrupt Status */
988#define PCI_EXP_DPC_RP_BUSY 0x0010 /* Root Port Busy */
989#define PCI_EXP_DPC_STATUS_TRIGGER_RSN_EXT 0x0060 /* Trig Reason Extension */
984 990
985#define PCI_EXP_DPC_SOURCE_ID 10 /* DPC Source Identifier */ 991#define PCI_EXP_DPC_SOURCE_ID 10 /* DPC Source Identifier */
986 992
987#define PCI_EXP_DPC_RP_PIO_STATUS 0x0C /* RP PIO Status */ 993#define PCI_EXP_DPC_RP_PIO_STATUS 0x0C /* RP PIO Status */
988#define PCI_EXP_DPC_RP_PIO_MASK 0x10 /* RP PIO MASK */ 994#define PCI_EXP_DPC_RP_PIO_MASK 0x10 /* RP PIO Mask */
989#define PCI_EXP_DPC_RP_PIO_SEVERITY 0x14 /* RP PIO Severity */ 995#define PCI_EXP_DPC_RP_PIO_SEVERITY 0x14 /* RP PIO Severity */
990#define PCI_EXP_DPC_RP_PIO_SYSERROR 0x18 /* RP PIO SysError */ 996#define PCI_EXP_DPC_RP_PIO_SYSERROR 0x18 /* RP PIO SysError */
991#define PCI_EXP_DPC_RP_PIO_EXCEPTION 0x1C /* RP PIO Exception */ 997#define PCI_EXP_DPC_RP_PIO_EXCEPTION 0x1C /* RP PIO Exception */
diff --git a/include/uapi/linux/switchtec_ioctl.h b/include/uapi/linux/switchtec_ioctl.h
index 75df44373034..4f4daf8db954 100644
--- a/include/uapi/linux/switchtec_ioctl.h
+++ b/include/uapi/linux/switchtec_ioctl.h
@@ -88,7 +88,8 @@ struct switchtec_ioctl_event_summary {
88#define SWITCHTEC_IOCTL_EVENT_FORCE_SPEED 26 88#define SWITCHTEC_IOCTL_EVENT_FORCE_SPEED 26
89#define SWITCHTEC_IOCTL_EVENT_CREDIT_TIMEOUT 27 89#define SWITCHTEC_IOCTL_EVENT_CREDIT_TIMEOUT 27
90#define SWITCHTEC_IOCTL_EVENT_LINK_STATE 28 90#define SWITCHTEC_IOCTL_EVENT_LINK_STATE 28
91#define SWITCHTEC_IOCTL_MAX_EVENTS 29 91#define SWITCHTEC_IOCTL_EVENT_GFMS 29
92#define SWITCHTEC_IOCTL_MAX_EVENTS 30
92 93
93#define SWITCHTEC_IOCTL_EVENT_LOCAL_PART_IDX -1 94#define SWITCHTEC_IOCTL_EVENT_LOCAL_PART_IDX -1
94#define SWITCHTEC_IOCTL_EVENT_IDX_ALL -2 95#define SWITCHTEC_IOCTL_EVENT_IDX_ALL -2
diff --git a/include/uapi/linux/uvcvideo.h b/include/uapi/linux/uvcvideo.h
index e80b4655d8cd..020714d2c5bd 100644
--- a/include/uapi/linux/uvcvideo.h
+++ b/include/uapi/linux/uvcvideo.h
@@ -68,4 +68,30 @@ struct uvc_xu_control_query {
68#define UVCIOC_CTRL_MAP _IOWR('u', 0x20, struct uvc_xu_control_mapping) 68#define UVCIOC_CTRL_MAP _IOWR('u', 0x20, struct uvc_xu_control_mapping)
69#define UVCIOC_CTRL_QUERY _IOWR('u', 0x21, struct uvc_xu_control_query) 69#define UVCIOC_CTRL_QUERY _IOWR('u', 0x21, struct uvc_xu_control_query)
70 70
71/*
72 * Metadata node
73 */
74
75/**
76 * struct uvc_meta_buf - metadata buffer building block
77 * @ns - system timestamp of the payload in nanoseconds
78 * @sof - USB Frame Number
79 * @length - length of the payload header
80 * @flags - payload header flags
81 * @buf - optional device-specific header data
82 *
83 * UVC metadata nodes fill buffers with possibly multiple instances of this
84 * struct. The first two fields are added by the driver, they can be used for
85 * clock synchronisation. The rest is an exact copy of a UVC payload header.
86 * Only complete objects with complete buffers are included. Therefore it's
87 * always sizeof(meta->ts) + sizeof(meta->sof) + meta->length bytes large.
88 */
89struct uvc_meta_buf {
90 __u64 ns;
91 __u16 sof;
92 __u8 length;
93 __u8 flags;
94 __u8 buf[];
95} __packed;
96
71#endif 97#endif
diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
index a692623e0236..cbbb750d87d1 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -67,8 +67,8 @@
67/* User-class control IDs */ 67/* User-class control IDs */
68 68
69#define V4L2_CID_BASE (V4L2_CTRL_CLASS_USER | 0x900) 69#define V4L2_CID_BASE (V4L2_CTRL_CLASS_USER | 0x900)
70#define V4L2_CID_USER_BASE V4L2_CID_BASE 70#define V4L2_CID_USER_BASE V4L2_CID_BASE
71#define V4L2_CID_USER_CLASS (V4L2_CTRL_CLASS_USER | 1) 71#define V4L2_CID_USER_CLASS (V4L2_CTRL_CLASS_USER | 1)
72#define V4L2_CID_BRIGHTNESS (V4L2_CID_BASE+0) 72#define V4L2_CID_BRIGHTNESS (V4L2_CID_BASE+0)
73#define V4L2_CID_CONTRAST (V4L2_CID_BASE+1) 73#define V4L2_CID_CONTRAST (V4L2_CID_BASE+1)
74#define V4L2_CID_SATURATION (V4L2_CID_BASE+2) 74#define V4L2_CID_SATURATION (V4L2_CID_BASE+2)
@@ -102,7 +102,7 @@ enum v4l2_power_line_frequency {
102#define V4L2_CID_HUE_AUTO (V4L2_CID_BASE+25) 102#define V4L2_CID_HUE_AUTO (V4L2_CID_BASE+25)
103#define V4L2_CID_WHITE_BALANCE_TEMPERATURE (V4L2_CID_BASE+26) 103#define V4L2_CID_WHITE_BALANCE_TEMPERATURE (V4L2_CID_BASE+26)
104#define V4L2_CID_SHARPNESS (V4L2_CID_BASE+27) 104#define V4L2_CID_SHARPNESS (V4L2_CID_BASE+27)
105#define V4L2_CID_BACKLIGHT_COMPENSATION (V4L2_CID_BASE+28) 105#define V4L2_CID_BACKLIGHT_COMPENSATION (V4L2_CID_BASE+28)
106#define V4L2_CID_CHROMA_AGC (V4L2_CID_BASE+29) 106#define V4L2_CID_CHROMA_AGC (V4L2_CID_BASE+29)
107#define V4L2_CID_COLOR_KILLER (V4L2_CID_BASE+30) 107#define V4L2_CID_COLOR_KILLER (V4L2_CID_BASE+30)
108#define V4L2_CID_COLORFX (V4L2_CID_BASE+31) 108#define V4L2_CID_COLORFX (V4L2_CID_BASE+31)
@@ -194,11 +194,11 @@ enum v4l2_colorfx {
194/* The MPEG controls are applicable to all codec controls 194/* The MPEG controls are applicable to all codec controls
195 * and the 'MPEG' part of the define is historical */ 195 * and the 'MPEG' part of the define is historical */
196 196
197#define V4L2_CID_MPEG_BASE (V4L2_CTRL_CLASS_MPEG | 0x900) 197#define V4L2_CID_MPEG_BASE (V4L2_CTRL_CLASS_MPEG | 0x900)
198#define V4L2_CID_MPEG_CLASS (V4L2_CTRL_CLASS_MPEG | 1) 198#define V4L2_CID_MPEG_CLASS (V4L2_CTRL_CLASS_MPEG | 1)
199 199
200/* MPEG streams, specific to multiplexed streams */ 200/* MPEG streams, specific to multiplexed streams */
201#define V4L2_CID_MPEG_STREAM_TYPE (V4L2_CID_MPEG_BASE+0) 201#define V4L2_CID_MPEG_STREAM_TYPE (V4L2_CID_MPEG_BASE+0)
202enum v4l2_mpeg_stream_type { 202enum v4l2_mpeg_stream_type {
203 V4L2_MPEG_STREAM_TYPE_MPEG2_PS = 0, /* MPEG-2 program stream */ 203 V4L2_MPEG_STREAM_TYPE_MPEG2_PS = 0, /* MPEG-2 program stream */
204 V4L2_MPEG_STREAM_TYPE_MPEG2_TS = 1, /* MPEG-2 transport stream */ 204 V4L2_MPEG_STREAM_TYPE_MPEG2_TS = 1, /* MPEG-2 transport stream */
@@ -207,26 +207,26 @@ enum v4l2_mpeg_stream_type {
207 V4L2_MPEG_STREAM_TYPE_MPEG1_VCD = 4, /* MPEG-1 VCD-compatible stream */ 207 V4L2_MPEG_STREAM_TYPE_MPEG1_VCD = 4, /* MPEG-1 VCD-compatible stream */
208 V4L2_MPEG_STREAM_TYPE_MPEG2_SVCD = 5, /* MPEG-2 SVCD-compatible stream */ 208 V4L2_MPEG_STREAM_TYPE_MPEG2_SVCD = 5, /* MPEG-2 SVCD-compatible stream */
209}; 209};
210#define V4L2_CID_MPEG_STREAM_PID_PMT (V4L2_CID_MPEG_BASE+1) 210#define V4L2_CID_MPEG_STREAM_PID_PMT (V4L2_CID_MPEG_BASE+1)
211#define V4L2_CID_MPEG_STREAM_PID_AUDIO (V4L2_CID_MPEG_BASE+2) 211#define V4L2_CID_MPEG_STREAM_PID_AUDIO (V4L2_CID_MPEG_BASE+2)
212#define V4L2_CID_MPEG_STREAM_PID_VIDEO (V4L2_CID_MPEG_BASE+3) 212#define V4L2_CID_MPEG_STREAM_PID_VIDEO (V4L2_CID_MPEG_BASE+3)
213#define V4L2_CID_MPEG_STREAM_PID_PCR (V4L2_CID_MPEG_BASE+4) 213#define V4L2_CID_MPEG_STREAM_PID_PCR (V4L2_CID_MPEG_BASE+4)
214#define V4L2_CID_MPEG_STREAM_PES_ID_AUDIO (V4L2_CID_MPEG_BASE+5) 214#define V4L2_CID_MPEG_STREAM_PES_ID_AUDIO (V4L2_CID_MPEG_BASE+5)
215#define V4L2_CID_MPEG_STREAM_PES_ID_VIDEO (V4L2_CID_MPEG_BASE+6) 215#define V4L2_CID_MPEG_STREAM_PES_ID_VIDEO (V4L2_CID_MPEG_BASE+6)
216#define V4L2_CID_MPEG_STREAM_VBI_FMT (V4L2_CID_MPEG_BASE+7) 216#define V4L2_CID_MPEG_STREAM_VBI_FMT (V4L2_CID_MPEG_BASE+7)
217enum v4l2_mpeg_stream_vbi_fmt { 217enum v4l2_mpeg_stream_vbi_fmt {
218 V4L2_MPEG_STREAM_VBI_FMT_NONE = 0, /* No VBI in the MPEG stream */ 218 V4L2_MPEG_STREAM_VBI_FMT_NONE = 0, /* No VBI in the MPEG stream */
219 V4L2_MPEG_STREAM_VBI_FMT_IVTV = 1, /* VBI in private packets, IVTV format */ 219 V4L2_MPEG_STREAM_VBI_FMT_IVTV = 1, /* VBI in private packets, IVTV format */
220}; 220};
221 221
222/* MPEG audio controls specific to multiplexed streams */ 222/* MPEG audio controls specific to multiplexed streams */
223#define V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ (V4L2_CID_MPEG_BASE+100) 223#define V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ (V4L2_CID_MPEG_BASE+100)
224enum v4l2_mpeg_audio_sampling_freq { 224enum v4l2_mpeg_audio_sampling_freq {
225 V4L2_MPEG_AUDIO_SAMPLING_FREQ_44100 = 0, 225 V4L2_MPEG_AUDIO_SAMPLING_FREQ_44100 = 0,
226 V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000 = 1, 226 V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000 = 1,
227 V4L2_MPEG_AUDIO_SAMPLING_FREQ_32000 = 2, 227 V4L2_MPEG_AUDIO_SAMPLING_FREQ_32000 = 2,
228}; 228};
229#define V4L2_CID_MPEG_AUDIO_ENCODING (V4L2_CID_MPEG_BASE+101) 229#define V4L2_CID_MPEG_AUDIO_ENCODING (V4L2_CID_MPEG_BASE+101)
230enum v4l2_mpeg_audio_encoding { 230enum v4l2_mpeg_audio_encoding {
231 V4L2_MPEG_AUDIO_ENCODING_LAYER_1 = 0, 231 V4L2_MPEG_AUDIO_ENCODING_LAYER_1 = 0,
232 V4L2_MPEG_AUDIO_ENCODING_LAYER_2 = 1, 232 V4L2_MPEG_AUDIO_ENCODING_LAYER_2 = 1,
@@ -234,7 +234,7 @@ enum v4l2_mpeg_audio_encoding {
234 V4L2_MPEG_AUDIO_ENCODING_AAC = 3, 234 V4L2_MPEG_AUDIO_ENCODING_AAC = 3,
235 V4L2_MPEG_AUDIO_ENCODING_AC3 = 4, 235 V4L2_MPEG_AUDIO_ENCODING_AC3 = 4,
236}; 236};
237#define V4L2_CID_MPEG_AUDIO_L1_BITRATE (V4L2_CID_MPEG_BASE+102) 237#define V4L2_CID_MPEG_AUDIO_L1_BITRATE (V4L2_CID_MPEG_BASE+102)
238enum v4l2_mpeg_audio_l1_bitrate { 238enum v4l2_mpeg_audio_l1_bitrate {
239 V4L2_MPEG_AUDIO_L1_BITRATE_32K = 0, 239 V4L2_MPEG_AUDIO_L1_BITRATE_32K = 0,
240 V4L2_MPEG_AUDIO_L1_BITRATE_64K = 1, 240 V4L2_MPEG_AUDIO_L1_BITRATE_64K = 1,
@@ -251,7 +251,7 @@ enum v4l2_mpeg_audio_l1_bitrate {
251 V4L2_MPEG_AUDIO_L1_BITRATE_416K = 12, 251 V4L2_MPEG_AUDIO_L1_BITRATE_416K = 12,
252 V4L2_MPEG_AUDIO_L1_BITRATE_448K = 13, 252 V4L2_MPEG_AUDIO_L1_BITRATE_448K = 13,
253}; 253};
254#define V4L2_CID_MPEG_AUDIO_L2_BITRATE (V4L2_CID_MPEG_BASE+103) 254#define V4L2_CID_MPEG_AUDIO_L2_BITRATE (V4L2_CID_MPEG_BASE+103)
255enum v4l2_mpeg_audio_l2_bitrate { 255enum v4l2_mpeg_audio_l2_bitrate {
256 V4L2_MPEG_AUDIO_L2_BITRATE_32K = 0, 256 V4L2_MPEG_AUDIO_L2_BITRATE_32K = 0,
257 V4L2_MPEG_AUDIO_L2_BITRATE_48K = 1, 257 V4L2_MPEG_AUDIO_L2_BITRATE_48K = 1,
@@ -268,7 +268,7 @@ enum v4l2_mpeg_audio_l2_bitrate {
268 V4L2_MPEG_AUDIO_L2_BITRATE_320K = 12, 268 V4L2_MPEG_AUDIO_L2_BITRATE_320K = 12,
269 V4L2_MPEG_AUDIO_L2_BITRATE_384K = 13, 269 V4L2_MPEG_AUDIO_L2_BITRATE_384K = 13,
270}; 270};
271#define V4L2_CID_MPEG_AUDIO_L3_BITRATE (V4L2_CID_MPEG_BASE+104) 271#define V4L2_CID_MPEG_AUDIO_L3_BITRATE (V4L2_CID_MPEG_BASE+104)
272enum v4l2_mpeg_audio_l3_bitrate { 272enum v4l2_mpeg_audio_l3_bitrate {
273 V4L2_MPEG_AUDIO_L3_BITRATE_32K = 0, 273 V4L2_MPEG_AUDIO_L3_BITRATE_32K = 0,
274 V4L2_MPEG_AUDIO_L3_BITRATE_40K = 1, 274 V4L2_MPEG_AUDIO_L3_BITRATE_40K = 1,
@@ -285,32 +285,32 @@ enum v4l2_mpeg_audio_l3_bitrate {
285 V4L2_MPEG_AUDIO_L3_BITRATE_256K = 12, 285 V4L2_MPEG_AUDIO_L3_BITRATE_256K = 12,
286 V4L2_MPEG_AUDIO_L3_BITRATE_320K = 13, 286 V4L2_MPEG_AUDIO_L3_BITRATE_320K = 13,
287}; 287};
288#define V4L2_CID_MPEG_AUDIO_MODE (V4L2_CID_MPEG_BASE+105) 288#define V4L2_CID_MPEG_AUDIO_MODE (V4L2_CID_MPEG_BASE+105)
289enum v4l2_mpeg_audio_mode { 289enum v4l2_mpeg_audio_mode {
290 V4L2_MPEG_AUDIO_MODE_STEREO = 0, 290 V4L2_MPEG_AUDIO_MODE_STEREO = 0,
291 V4L2_MPEG_AUDIO_MODE_JOINT_STEREO = 1, 291 V4L2_MPEG_AUDIO_MODE_JOINT_STEREO = 1,
292 V4L2_MPEG_AUDIO_MODE_DUAL = 2, 292 V4L2_MPEG_AUDIO_MODE_DUAL = 2,
293 V4L2_MPEG_AUDIO_MODE_MONO = 3, 293 V4L2_MPEG_AUDIO_MODE_MONO = 3,
294}; 294};
295#define V4L2_CID_MPEG_AUDIO_MODE_EXTENSION (V4L2_CID_MPEG_BASE+106) 295#define V4L2_CID_MPEG_AUDIO_MODE_EXTENSION (V4L2_CID_MPEG_BASE+106)
296enum v4l2_mpeg_audio_mode_extension { 296enum v4l2_mpeg_audio_mode_extension {
297 V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_4 = 0, 297 V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_4 = 0,
298 V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_8 = 1, 298 V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_8 = 1,
299 V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_12 = 2, 299 V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_12 = 2,
300 V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_16 = 3, 300 V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_16 = 3,
301}; 301};
302#define V4L2_CID_MPEG_AUDIO_EMPHASIS (V4L2_CID_MPEG_BASE+107) 302#define V4L2_CID_MPEG_AUDIO_EMPHASIS (V4L2_CID_MPEG_BASE+107)
303enum v4l2_mpeg_audio_emphasis { 303enum v4l2_mpeg_audio_emphasis {
304 V4L2_MPEG_AUDIO_EMPHASIS_NONE = 0, 304 V4L2_MPEG_AUDIO_EMPHASIS_NONE = 0,
305 V4L2_MPEG_AUDIO_EMPHASIS_50_DIV_15_uS = 1, 305 V4L2_MPEG_AUDIO_EMPHASIS_50_DIV_15_uS = 1,
306 V4L2_MPEG_AUDIO_EMPHASIS_CCITT_J17 = 2, 306 V4L2_MPEG_AUDIO_EMPHASIS_CCITT_J17 = 2,
307}; 307};
308#define V4L2_CID_MPEG_AUDIO_CRC (V4L2_CID_MPEG_BASE+108) 308#define V4L2_CID_MPEG_AUDIO_CRC (V4L2_CID_MPEG_BASE+108)
309enum v4l2_mpeg_audio_crc { 309enum v4l2_mpeg_audio_crc {
310 V4L2_MPEG_AUDIO_CRC_NONE = 0, 310 V4L2_MPEG_AUDIO_CRC_NONE = 0,
311 V4L2_MPEG_AUDIO_CRC_CRC16 = 1, 311 V4L2_MPEG_AUDIO_CRC_CRC16 = 1,
312}; 312};
313#define V4L2_CID_MPEG_AUDIO_MUTE (V4L2_CID_MPEG_BASE+109) 313#define V4L2_CID_MPEG_AUDIO_MUTE (V4L2_CID_MPEG_BASE+109)
314#define V4L2_CID_MPEG_AUDIO_AAC_BITRATE (V4L2_CID_MPEG_BASE+110) 314#define V4L2_CID_MPEG_AUDIO_AAC_BITRATE (V4L2_CID_MPEG_BASE+110)
315#define V4L2_CID_MPEG_AUDIO_AC3_BITRATE (V4L2_CID_MPEG_BASE+111) 315#define V4L2_CID_MPEG_AUDIO_AC3_BITRATE (V4L2_CID_MPEG_BASE+111)
316enum v4l2_mpeg_audio_ac3_bitrate { 316enum v4l2_mpeg_audio_ac3_bitrate {
@@ -346,33 +346,33 @@ enum v4l2_mpeg_audio_dec_playback {
346#define V4L2_CID_MPEG_AUDIO_DEC_MULTILINGUAL_PLAYBACK (V4L2_CID_MPEG_BASE+113) 346#define V4L2_CID_MPEG_AUDIO_DEC_MULTILINGUAL_PLAYBACK (V4L2_CID_MPEG_BASE+113)
347 347
348/* MPEG video controls specific to multiplexed streams */ 348/* MPEG video controls specific to multiplexed streams */
349#define V4L2_CID_MPEG_VIDEO_ENCODING (V4L2_CID_MPEG_BASE+200) 349#define V4L2_CID_MPEG_VIDEO_ENCODING (V4L2_CID_MPEG_BASE+200)
350enum v4l2_mpeg_video_encoding { 350enum v4l2_mpeg_video_encoding {
351 V4L2_MPEG_VIDEO_ENCODING_MPEG_1 = 0, 351 V4L2_MPEG_VIDEO_ENCODING_MPEG_1 = 0,
352 V4L2_MPEG_VIDEO_ENCODING_MPEG_2 = 1, 352 V4L2_MPEG_VIDEO_ENCODING_MPEG_2 = 1,
353 V4L2_MPEG_VIDEO_ENCODING_MPEG_4_AVC = 2, 353 V4L2_MPEG_VIDEO_ENCODING_MPEG_4_AVC = 2,
354}; 354};
355#define V4L2_CID_MPEG_VIDEO_ASPECT (V4L2_CID_MPEG_BASE+201) 355#define V4L2_CID_MPEG_VIDEO_ASPECT (V4L2_CID_MPEG_BASE+201)
356enum v4l2_mpeg_video_aspect { 356enum v4l2_mpeg_video_aspect {
357 V4L2_MPEG_VIDEO_ASPECT_1x1 = 0, 357 V4L2_MPEG_VIDEO_ASPECT_1x1 = 0,
358 V4L2_MPEG_VIDEO_ASPECT_4x3 = 1, 358 V4L2_MPEG_VIDEO_ASPECT_4x3 = 1,
359 V4L2_MPEG_VIDEO_ASPECT_16x9 = 2, 359 V4L2_MPEG_VIDEO_ASPECT_16x9 = 2,
360 V4L2_MPEG_VIDEO_ASPECT_221x100 = 3, 360 V4L2_MPEG_VIDEO_ASPECT_221x100 = 3,
361}; 361};
362#define V4L2_CID_MPEG_VIDEO_B_FRAMES (V4L2_CID_MPEG_BASE+202) 362#define V4L2_CID_MPEG_VIDEO_B_FRAMES (V4L2_CID_MPEG_BASE+202)
363#define V4L2_CID_MPEG_VIDEO_GOP_SIZE (V4L2_CID_MPEG_BASE+203) 363#define V4L2_CID_MPEG_VIDEO_GOP_SIZE (V4L2_CID_MPEG_BASE+203)
364#define V4L2_CID_MPEG_VIDEO_GOP_CLOSURE (V4L2_CID_MPEG_BASE+204) 364#define V4L2_CID_MPEG_VIDEO_GOP_CLOSURE (V4L2_CID_MPEG_BASE+204)
365#define V4L2_CID_MPEG_VIDEO_PULLDOWN (V4L2_CID_MPEG_BASE+205) 365#define V4L2_CID_MPEG_VIDEO_PULLDOWN (V4L2_CID_MPEG_BASE+205)
366#define V4L2_CID_MPEG_VIDEO_BITRATE_MODE (V4L2_CID_MPEG_BASE+206) 366#define V4L2_CID_MPEG_VIDEO_BITRATE_MODE (V4L2_CID_MPEG_BASE+206)
367enum v4l2_mpeg_video_bitrate_mode { 367enum v4l2_mpeg_video_bitrate_mode {
368 V4L2_MPEG_VIDEO_BITRATE_MODE_VBR = 0, 368 V4L2_MPEG_VIDEO_BITRATE_MODE_VBR = 0,
369 V4L2_MPEG_VIDEO_BITRATE_MODE_CBR = 1, 369 V4L2_MPEG_VIDEO_BITRATE_MODE_CBR = 1,
370}; 370};
371#define V4L2_CID_MPEG_VIDEO_BITRATE (V4L2_CID_MPEG_BASE+207) 371#define V4L2_CID_MPEG_VIDEO_BITRATE (V4L2_CID_MPEG_BASE+207)
372#define V4L2_CID_MPEG_VIDEO_BITRATE_PEAK (V4L2_CID_MPEG_BASE+208) 372#define V4L2_CID_MPEG_VIDEO_BITRATE_PEAK (V4L2_CID_MPEG_BASE+208)
373#define V4L2_CID_MPEG_VIDEO_TEMPORAL_DECIMATION (V4L2_CID_MPEG_BASE+209) 373#define V4L2_CID_MPEG_VIDEO_TEMPORAL_DECIMATION (V4L2_CID_MPEG_BASE+209)
374#define V4L2_CID_MPEG_VIDEO_MUTE (V4L2_CID_MPEG_BASE+210) 374#define V4L2_CID_MPEG_VIDEO_MUTE (V4L2_CID_MPEG_BASE+210)
375#define V4L2_CID_MPEG_VIDEO_MUTE_YUV (V4L2_CID_MPEG_BASE+211) 375#define V4L2_CID_MPEG_VIDEO_MUTE_YUV (V4L2_CID_MPEG_BASE+211)
376#define V4L2_CID_MPEG_VIDEO_DECODER_SLICE_INTERFACE (V4L2_CID_MPEG_BASE+212) 376#define V4L2_CID_MPEG_VIDEO_DECODER_SLICE_INTERFACE (V4L2_CID_MPEG_BASE+212)
377#define V4L2_CID_MPEG_VIDEO_DECODER_MPEG4_DEBLOCK_FILTER (V4L2_CID_MPEG_BASE+213) 377#define V4L2_CID_MPEG_VIDEO_DECODER_MPEG4_DEBLOCK_FILTER (V4L2_CID_MPEG_BASE+213)
378#define V4L2_CID_MPEG_VIDEO_CYCLIC_INTRA_REFRESH_MB (V4L2_CID_MPEG_BASE+214) 378#define V4L2_CID_MPEG_VIDEO_CYCLIC_INTRA_REFRESH_MB (V4L2_CID_MPEG_BASE+214)
@@ -590,14 +590,14 @@ enum v4l2_vp8_golden_frame_sel {
590#define V4L2_CID_MPEG_VIDEO_VPX_PROFILE (V4L2_CID_MPEG_BASE+511) 590#define V4L2_CID_MPEG_VIDEO_VPX_PROFILE (V4L2_CID_MPEG_BASE+511)
591 591
592/* MPEG-class control IDs specific to the CX2341x driver as defined by V4L2 */ 592/* MPEG-class control IDs specific to the CX2341x driver as defined by V4L2 */
593#define V4L2_CID_MPEG_CX2341X_BASE (V4L2_CTRL_CLASS_MPEG | 0x1000) 593#define V4L2_CID_MPEG_CX2341X_BASE (V4L2_CTRL_CLASS_MPEG | 0x1000)
594#define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE (V4L2_CID_MPEG_CX2341X_BASE+0) 594#define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE (V4L2_CID_MPEG_CX2341X_BASE+0)
595enum v4l2_mpeg_cx2341x_video_spatial_filter_mode { 595enum v4l2_mpeg_cx2341x_video_spatial_filter_mode {
596 V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_MANUAL = 0, 596 V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_MANUAL = 0,
597 V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_AUTO = 1, 597 V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_AUTO = 1,
598}; 598};
599#define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER (V4L2_CID_MPEG_CX2341X_BASE+1) 599#define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER (V4L2_CID_MPEG_CX2341X_BASE+1)
600#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE (V4L2_CID_MPEG_CX2341X_BASE+2) 600#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE (V4L2_CID_MPEG_CX2341X_BASE+2)
601enum v4l2_mpeg_cx2341x_video_luma_spatial_filter_type { 601enum v4l2_mpeg_cx2341x_video_luma_spatial_filter_type {
602 V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_OFF = 0, 602 V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_OFF = 0,
603 V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_1D_HOR = 1, 603 V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_1D_HOR = 1,
@@ -605,18 +605,18 @@ enum v4l2_mpeg_cx2341x_video_luma_spatial_filter_type {
605 V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_2D_HV_SEPARABLE = 3, 605 V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_2D_HV_SEPARABLE = 3,
606 V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_2D_SYM_NON_SEPARABLE = 4, 606 V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_2D_SYM_NON_SEPARABLE = 4,
607}; 607};
608#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE (V4L2_CID_MPEG_CX2341X_BASE+3) 608#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE (V4L2_CID_MPEG_CX2341X_BASE+3)
609enum v4l2_mpeg_cx2341x_video_chroma_spatial_filter_type { 609enum v4l2_mpeg_cx2341x_video_chroma_spatial_filter_type {
610 V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_OFF = 0, 610 V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_OFF = 0,
611 V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_1D_HOR = 1, 611 V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_1D_HOR = 1,
612}; 612};
613#define V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE (V4L2_CID_MPEG_CX2341X_BASE+4) 613#define V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE (V4L2_CID_MPEG_CX2341X_BASE+4)
614enum v4l2_mpeg_cx2341x_video_temporal_filter_mode { 614enum v4l2_mpeg_cx2341x_video_temporal_filter_mode {
615 V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_MANUAL = 0, 615 V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_MANUAL = 0,
616 V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_AUTO = 1, 616 V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_AUTO = 1,
617}; 617};
618#define V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER (V4L2_CID_MPEG_CX2341X_BASE+5) 618#define V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER (V4L2_CID_MPEG_CX2341X_BASE+5)
619#define V4L2_CID_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE (V4L2_CID_MPEG_CX2341X_BASE+6) 619#define V4L2_CID_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE (V4L2_CID_MPEG_CX2341X_BASE+6)
620enum v4l2_mpeg_cx2341x_video_median_filter_type { 620enum v4l2_mpeg_cx2341x_video_median_filter_type {
621 V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_OFF = 0, 621 V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_OFF = 0,
622 V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_HOR = 1, 622 V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_HOR = 1,
@@ -624,11 +624,11 @@ enum v4l2_mpeg_cx2341x_video_median_filter_type {
624 V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_HOR_VERT = 3, 624 V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_HOR_VERT = 3,
625 V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_DIAG = 4, 625 V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_DIAG = 4,
626}; 626};
627#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_BOTTOM (V4L2_CID_MPEG_CX2341X_BASE+7) 627#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_BOTTOM (V4L2_CID_MPEG_CX2341X_BASE+7)
628#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_TOP (V4L2_CID_MPEG_CX2341X_BASE+8) 628#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_TOP (V4L2_CID_MPEG_CX2341X_BASE+8)
629#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_BOTTOM (V4L2_CID_MPEG_CX2341X_BASE+9) 629#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_BOTTOM (V4L2_CID_MPEG_CX2341X_BASE+9)
630#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_TOP (V4L2_CID_MPEG_CX2341X_BASE+10) 630#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_TOP (V4L2_CID_MPEG_CX2341X_BASE+10)
631#define V4L2_CID_MPEG_CX2341X_STREAM_INSERT_NAV_PACKETS (V4L2_CID_MPEG_CX2341X_BASE+11) 631#define V4L2_CID_MPEG_CX2341X_STREAM_INSERT_NAV_PACKETS (V4L2_CID_MPEG_CX2341X_BASE+11)
632 632
633/* MPEG-class control IDs specific to the Samsung MFC 5.1 driver as defined by V4L2 */ 633/* MPEG-class control IDs specific to the Samsung MFC 5.1 driver as defined by V4L2 */
634#define V4L2_CID_MPEG_MFC51_BASE (V4L2_CTRL_CLASS_MPEG | 0x1100) 634#define V4L2_CID_MPEG_MFC51_BASE (V4L2_CTRL_CLASS_MPEG | 0x1100)
@@ -660,8 +660,8 @@ enum v4l2_mpeg_mfc51_video_force_frame_type {
660 660
661/* Camera class control IDs */ 661/* Camera class control IDs */
662 662
663#define V4L2_CID_CAMERA_CLASS_BASE (V4L2_CTRL_CLASS_CAMERA | 0x900) 663#define V4L2_CID_CAMERA_CLASS_BASE (V4L2_CTRL_CLASS_CAMERA | 0x900)
664#define V4L2_CID_CAMERA_CLASS (V4L2_CTRL_CLASS_CAMERA | 1) 664#define V4L2_CID_CAMERA_CLASS (V4L2_CTRL_CLASS_CAMERA | 1)
665 665
666#define V4L2_CID_EXPOSURE_AUTO (V4L2_CID_CAMERA_CLASS_BASE+1) 666#define V4L2_CID_EXPOSURE_AUTO (V4L2_CID_CAMERA_CLASS_BASE+1)
667enum v4l2_exposure_auto_type { 667enum v4l2_exposure_auto_type {
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 1c095b5a99c5..982718965180 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -107,14 +107,14 @@ enum v4l2_field {
107 transmitted first */ 107 transmitted first */
108}; 108};
109#define V4L2_FIELD_HAS_TOP(field) \ 109#define V4L2_FIELD_HAS_TOP(field) \
110 ((field) == V4L2_FIELD_TOP ||\ 110 ((field) == V4L2_FIELD_TOP ||\
111 (field) == V4L2_FIELD_INTERLACED ||\ 111 (field) == V4L2_FIELD_INTERLACED ||\
112 (field) == V4L2_FIELD_INTERLACED_TB ||\ 112 (field) == V4L2_FIELD_INTERLACED_TB ||\
113 (field) == V4L2_FIELD_INTERLACED_BT ||\ 113 (field) == V4L2_FIELD_INTERLACED_BT ||\
114 (field) == V4L2_FIELD_SEQ_TB ||\ 114 (field) == V4L2_FIELD_SEQ_TB ||\
115 (field) == V4L2_FIELD_SEQ_BT) 115 (field) == V4L2_FIELD_SEQ_BT)
116#define V4L2_FIELD_HAS_BOTTOM(field) \ 116#define V4L2_FIELD_HAS_BOTTOM(field) \
117 ((field) == V4L2_FIELD_BOTTOM ||\ 117 ((field) == V4L2_FIELD_BOTTOM ||\
118 (field) == V4L2_FIELD_INTERLACED ||\ 118 (field) == V4L2_FIELD_INTERLACED ||\
119 (field) == V4L2_FIELD_INTERLACED_TB ||\ 119 (field) == V4L2_FIELD_INTERLACED_TB ||\
120 (field) == V4L2_FIELD_INTERLACED_BT ||\ 120 (field) == V4L2_FIELD_INTERLACED_BT ||\
@@ -467,12 +467,12 @@ struct v4l2_capability {
467 * V I D E O I M A G E F O R M A T 467 * V I D E O I M A G E F O R M A T
468 */ 468 */
469struct v4l2_pix_format { 469struct v4l2_pix_format {
470 __u32 width; 470 __u32 width;
471 __u32 height; 471 __u32 height;
472 __u32 pixelformat; 472 __u32 pixelformat;
473 __u32 field; /* enum v4l2_field */ 473 __u32 field; /* enum v4l2_field */
474 __u32 bytesperline; /* for padding, zero if unused */ 474 __u32 bytesperline; /* for padding, zero if unused */
475 __u32 sizeimage; 475 __u32 sizeimage;
476 __u32 colorspace; /* enum v4l2_colorspace */ 476 __u32 colorspace; /* enum v4l2_colorspace */
477 __u32 priv; /* private data, depends on pixelformat */ 477 __u32 priv; /* private data, depends on pixelformat */
478 __u32 flags; /* format flags (V4L2_PIX_FMT_FLAG_*) */ 478 __u32 flags; /* format flags (V4L2_PIX_FMT_FLAG_*) */
@@ -669,6 +669,12 @@ struct v4l2_pix_format {
669#define V4L2_PIX_FMT_MT21C v4l2_fourcc('M', 'T', '2', '1') /* Mediatek compressed block mode */ 669#define V4L2_PIX_FMT_MT21C v4l2_fourcc('M', 'T', '2', '1') /* Mediatek compressed block mode */
670#define V4L2_PIX_FMT_INZI v4l2_fourcc('I', 'N', 'Z', 'I') /* Intel Planar Greyscale 10-bit and Depth 16-bit */ 670#define V4L2_PIX_FMT_INZI v4l2_fourcc('I', 'N', 'Z', 'I') /* Intel Planar Greyscale 10-bit and Depth 16-bit */
671 671
672/* 10bit raw bayer packed, 32 bytes for every 25 pixels, last LSB 6 bits unused */
673#define V4L2_PIX_FMT_IPU3_SBGGR10 v4l2_fourcc('i', 'p', '3', 'b') /* IPU3 packed 10-bit BGGR bayer */
674#define V4L2_PIX_FMT_IPU3_SGBRG10 v4l2_fourcc('i', 'p', '3', 'g') /* IPU3 packed 10-bit GBRG bayer */
675#define V4L2_PIX_FMT_IPU3_SGRBG10 v4l2_fourcc('i', 'p', '3', 'G') /* IPU3 packed 10-bit GRBG bayer */
676#define V4L2_PIX_FMT_IPU3_SRGGB10 v4l2_fourcc('i', 'p', '3', 'r') /* IPU3 packed 10-bit RGGB bayer */
677
672/* SDR formats - used only for Software Defined Radio devices */ 678/* SDR formats - used only for Software Defined Radio devices */
673#define V4L2_SDR_FMT_CU8 v4l2_fourcc('C', 'U', '0', '8') /* IQ u8 */ 679#define V4L2_SDR_FMT_CU8 v4l2_fourcc('C', 'U', '0', '8') /* IQ u8 */
674#define V4L2_SDR_FMT_CU16LE v4l2_fourcc('C', 'U', '1', '6') /* IQ u16le */ 680#define V4L2_SDR_FMT_CU16LE v4l2_fourcc('C', 'U', '1', '6') /* IQ u16le */
@@ -688,6 +694,7 @@ struct v4l2_pix_format {
688/* Meta-data formats */ 694/* Meta-data formats */
689#define V4L2_META_FMT_VSP1_HGO v4l2_fourcc('V', 'S', 'P', 'H') /* R-Car VSP1 1-D Histogram */ 695#define V4L2_META_FMT_VSP1_HGO v4l2_fourcc('V', 'S', 'P', 'H') /* R-Car VSP1 1-D Histogram */
690#define V4L2_META_FMT_VSP1_HGT v4l2_fourcc('V', 'S', 'P', 'T') /* R-Car VSP1 2-D Histogram */ 696#define V4L2_META_FMT_VSP1_HGT v4l2_fourcc('V', 'S', 'P', 'T') /* R-Car VSP1 2-D Histogram */
697#define V4L2_META_FMT_UVC v4l2_fourcc('U', 'V', 'C', 'H') /* UVC Payload Header metadata */
691 698
692/* priv field value to indicates that subsequent fields are valid. */ 699/* priv field value to indicates that subsequent fields are valid. */
693#define V4L2_PIX_FMT_PRIV_MAGIC 0xfeedcafe 700#define V4L2_PIX_FMT_PRIV_MAGIC 0xfeedcafe
@@ -1166,7 +1173,7 @@ typedef __u64 v4l2_std_id;
1166 V4L2_STD_NTSC_M_JP |\ 1173 V4L2_STD_NTSC_M_JP |\
1167 V4L2_STD_NTSC_M_KR) 1174 V4L2_STD_NTSC_M_KR)
1168/* Secam macros */ 1175/* Secam macros */
1169#define V4L2_STD_SECAM_DK (V4L2_STD_SECAM_D |\ 1176#define V4L2_STD_SECAM_DK (V4L2_STD_SECAM_D |\
1170 V4L2_STD_SECAM_K |\ 1177 V4L2_STD_SECAM_K |\
1171 V4L2_STD_SECAM_K1) 1178 V4L2_STD_SECAM_K1)
1172/* All Secam Standards */ 1179/* All Secam Standards */
@@ -1247,7 +1254,7 @@ struct v4l2_standard {
1247}; 1254};
1248 1255
1249/* 1256/*
1250 * D V B T T I M I N G S 1257 * D V B T T I M I N G S
1251 */ 1258 */
1252 1259
1253/** struct v4l2_bt_timings - BT.656/BT.1120 timing data 1260/** struct v4l2_bt_timings - BT.656/BT.1120 timing data
@@ -1588,7 +1595,7 @@ struct v4l2_ext_controls {
1588 struct v4l2_ext_control *controls; 1595 struct v4l2_ext_control *controls;
1589}; 1596};
1590 1597
1591#define V4L2_CTRL_ID_MASK (0x0fffffff) 1598#define V4L2_CTRL_ID_MASK (0x0fffffff)
1592#ifndef __KERNEL__ 1599#ifndef __KERNEL__
1593#define V4L2_CTRL_ID2CLASS(id) ((id) & 0x0fff0000UL) 1600#define V4L2_CTRL_ID2CLASS(id) ((id) & 0x0fff0000UL)
1594#endif 1601#endif
@@ -1660,11 +1667,11 @@ struct v4l2_querymenu {
1660/* Control flags */ 1667/* Control flags */
1661#define V4L2_CTRL_FLAG_DISABLED 0x0001 1668#define V4L2_CTRL_FLAG_DISABLED 0x0001
1662#define V4L2_CTRL_FLAG_GRABBED 0x0002 1669#define V4L2_CTRL_FLAG_GRABBED 0x0002
1663#define V4L2_CTRL_FLAG_READ_ONLY 0x0004 1670#define V4L2_CTRL_FLAG_READ_ONLY 0x0004
1664#define V4L2_CTRL_FLAG_UPDATE 0x0008 1671#define V4L2_CTRL_FLAG_UPDATE 0x0008
1665#define V4L2_CTRL_FLAG_INACTIVE 0x0010 1672#define V4L2_CTRL_FLAG_INACTIVE 0x0010
1666#define V4L2_CTRL_FLAG_SLIDER 0x0020 1673#define V4L2_CTRL_FLAG_SLIDER 0x0020
1667#define V4L2_CTRL_FLAG_WRITE_ONLY 0x0040 1674#define V4L2_CTRL_FLAG_WRITE_ONLY 0x0040
1668#define V4L2_CTRL_FLAG_VOLATILE 0x0080 1675#define V4L2_CTRL_FLAG_VOLATILE 0x0080
1669#define V4L2_CTRL_FLAG_HAS_PAYLOAD 0x0100 1676#define V4L2_CTRL_FLAG_HAS_PAYLOAD 0x0100
1670#define V4L2_CTRL_FLAG_EXECUTE_ON_WRITE 0x0200 1677#define V4L2_CTRL_FLAG_EXECUTE_ON_WRITE 0x0200
@@ -1778,21 +1785,21 @@ struct v4l2_hw_freq_seek {
1778 */ 1785 */
1779 1786
1780struct v4l2_rds_data { 1787struct v4l2_rds_data {
1781 __u8 lsb; 1788 __u8 lsb;
1782 __u8 msb; 1789 __u8 msb;
1783 __u8 block; 1790 __u8 block;
1784} __attribute__ ((packed)); 1791} __attribute__ ((packed));
1785 1792
1786#define V4L2_RDS_BLOCK_MSK 0x7 1793#define V4L2_RDS_BLOCK_MSK 0x7
1787#define V4L2_RDS_BLOCK_A 0 1794#define V4L2_RDS_BLOCK_A 0
1788#define V4L2_RDS_BLOCK_B 1 1795#define V4L2_RDS_BLOCK_B 1
1789#define V4L2_RDS_BLOCK_C 2 1796#define V4L2_RDS_BLOCK_C 2
1790#define V4L2_RDS_BLOCK_D 3 1797#define V4L2_RDS_BLOCK_D 3
1791#define V4L2_RDS_BLOCK_C_ALT 4 1798#define V4L2_RDS_BLOCK_C_ALT 4
1792#define V4L2_RDS_BLOCK_INVALID 7 1799#define V4L2_RDS_BLOCK_INVALID 7
1793 1800
1794#define V4L2_RDS_BLOCK_CORRECTED 0x40 1801#define V4L2_RDS_BLOCK_CORRECTED 0x40
1795#define V4L2_RDS_BLOCK_ERROR 0x80 1802#define V4L2_RDS_BLOCK_ERROR 0x80
1796 1803
1797/* 1804/*
1798 * A U D I O 1805 * A U D I O
@@ -2348,8 +2355,8 @@ struct v4l2_create_buffers {
2348#define VIDIOC_S_CROP _IOW('V', 60, struct v4l2_crop) 2355#define VIDIOC_S_CROP _IOW('V', 60, struct v4l2_crop)
2349#define VIDIOC_G_JPEGCOMP _IOR('V', 61, struct v4l2_jpegcompression) 2356#define VIDIOC_G_JPEGCOMP _IOR('V', 61, struct v4l2_jpegcompression)
2350#define VIDIOC_S_JPEGCOMP _IOW('V', 62, struct v4l2_jpegcompression) 2357#define VIDIOC_S_JPEGCOMP _IOW('V', 62, struct v4l2_jpegcompression)
2351#define VIDIOC_QUERYSTD _IOR('V', 63, v4l2_std_id) 2358#define VIDIOC_QUERYSTD _IOR('V', 63, v4l2_std_id)
2352#define VIDIOC_TRY_FMT _IOWR('V', 64, struct v4l2_format) 2359#define VIDIOC_TRY_FMT _IOWR('V', 64, struct v4l2_format)
2353#define VIDIOC_ENUMAUDIO _IOWR('V', 65, struct v4l2_audio) 2360#define VIDIOC_ENUMAUDIO _IOWR('V', 65, struct v4l2_audio)
2354#define VIDIOC_ENUMAUDOUT _IOWR('V', 66, struct v4l2_audioout) 2361#define VIDIOC_ENUMAUDOUT _IOWR('V', 66, struct v4l2_audioout)
2355#define VIDIOC_G_PRIORITY _IOR('V', 67, __u32) /* enum v4l2_priority */ 2362#define VIDIOC_G_PRIORITY _IOR('V', 67, __u32) /* enum v4l2_priority */
@@ -2370,8 +2377,8 @@ struct v4l2_create_buffers {
2370 * Only implemented if CONFIG_VIDEO_ADV_DEBUG is defined. 2377 * Only implemented if CONFIG_VIDEO_ADV_DEBUG is defined.
2371 * You must be root to use these ioctls. Never use these in applications! 2378 * You must be root to use these ioctls. Never use these in applications!
2372 */ 2379 */
2373#define VIDIOC_DBG_S_REGISTER _IOW('V', 79, struct v4l2_dbg_register) 2380#define VIDIOC_DBG_S_REGISTER _IOW('V', 79, struct v4l2_dbg_register)
2374#define VIDIOC_DBG_G_REGISTER _IOWR('V', 80, struct v4l2_dbg_register) 2381#define VIDIOC_DBG_G_REGISTER _IOWR('V', 80, struct v4l2_dbg_register)
2375 2382
2376#define VIDIOC_S_HW_FREQ_SEEK _IOW('V', 82, struct v4l2_hw_freq_seek) 2383#define VIDIOC_S_HW_FREQ_SEEK _IOW('V', 82, struct v4l2_hw_freq_seek)
2377#define VIDIOC_S_DV_TIMINGS _IOWR('V', 87, struct v4l2_dv_timings) 2384#define VIDIOC_S_DV_TIMINGS _IOWR('V', 87, struct v4l2_dv_timings)
diff --git a/include/uapi/rdma/rdma_netlink.h b/include/uapi/rdma/rdma_netlink.h
index 17e59bec169e..4c77e2a7b07e 100644
--- a/include/uapi/rdma/rdma_netlink.h
+++ b/include/uapi/rdma/rdma_netlink.h
@@ -227,16 +227,14 @@ enum rdma_nldev_command {
227 RDMA_NLDEV_CMD_UNSPEC, 227 RDMA_NLDEV_CMD_UNSPEC,
228 228
229 RDMA_NLDEV_CMD_GET, /* can dump */ 229 RDMA_NLDEV_CMD_GET, /* can dump */
230 RDMA_NLDEV_CMD_SET,
231 RDMA_NLDEV_CMD_NEW,
232 RDMA_NLDEV_CMD_DEL,
233 230
234 RDMA_NLDEV_CMD_PORT_GET, /* can dump */ 231 /* 2 - 4 are free to use */
235 RDMA_NLDEV_CMD_PORT_SET,
236 RDMA_NLDEV_CMD_PORT_NEW,
237 RDMA_NLDEV_CMD_PORT_DEL,
238 232
239 RDMA_NLDEV_CMD_RES_GET, /* can dump */ 233 RDMA_NLDEV_CMD_PORT_GET = 5, /* can dump */
234
235 /* 6 - 8 are free to use */
236
237 RDMA_NLDEV_CMD_RES_GET = 9, /* can dump */
240 238
241 RDMA_NLDEV_CMD_RES_QP_GET, /* can dump */ 239 RDMA_NLDEV_CMD_RES_QP_GET, /* can dump */
242 240