~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to include/media/v4l2-subdev.h

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno, Martin Michlmayr
  • Date: 2011-04-06 13:53:30 UTC
  • mfrom: (43.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20110406135330-wjufxhd0tvn3zx4z
Tags: 2.6.38-3
[ Ben Hutchings ]
* [ppc64] Add to linux-tools package architectures (Closes: #620124)
* [amd64] Save cr4 to mmu_cr4_features at boot time (Closes: #620284)
* appletalk: Fix bugs introduced when removing use of BKL
* ALSA: Fix yet another race in disconnection
* cciss: Fix lost command issue
* ath9k: Fix kernel panic in AR2427
* ses: Avoid kernel panic when lun 0 is not mapped
* PCI/ACPI: Report ASPM support to BIOS if not disabled from command line

[ Aurelien Jarno ]
* rtlwifi: fix build when PCI is not enabled.

[ Martin Michlmayr ]
* rtlwifi: Eliminate udelay calls with too large values (Closes: #620204)

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
#define _V4L2_SUBDEV_H
23
23
 
24
24
#include <media/v4l2-common.h>
 
25
#include <media/v4l2-mediabus.h>
 
26
 
 
27
/* generic v4l2_device notify callback notification values */
 
28
#define V4L2_SUBDEV_IR_RX_NOTIFY                _IOW('v', 0, u32)
 
29
#define V4L2_SUBDEV_IR_RX_FIFO_SERVICE_REQ      0x00000001
 
30
#define V4L2_SUBDEV_IR_RX_END_OF_RX_DETECTED    0x00000002
 
31
#define V4L2_SUBDEV_IR_RX_HW_FIFO_OVERRUN       0x00000004
 
32
#define V4L2_SUBDEV_IR_RX_SW_FIFO_OVERRUN       0x00000008
 
33
 
 
34
#define V4L2_SUBDEV_IR_TX_NOTIFY                _IOW('v', 1, u32)
 
35
#define V4L2_SUBDEV_IR_TX_FIFO_SERVICE_REQ      0x00000001
25
36
 
26
37
struct v4l2_device;
 
38
struct v4l2_ctrl_handler;
27
39
struct v4l2_subdev;
28
40
struct tuner_setup;
29
41
 
79
91
   not yet implemented) since ops provide proper type-checking.
80
92
 */
81
93
 
82
 
/* s_config: if set, then it is always called by the v4l2_i2c_new_subdev*
83
 
        functions after the v4l2_subdev was registered. It is used to pass
84
 
        platform data to the subdev which can be used during initialization.
 
94
/* Subdevice external IO pin configuration */
 
95
#define V4L2_SUBDEV_IO_PIN_DISABLE      (1 << 0) /* ENABLE assumed */
 
96
#define V4L2_SUBDEV_IO_PIN_OUTPUT       (1 << 1)
 
97
#define V4L2_SUBDEV_IO_PIN_INPUT        (1 << 2)
 
98
#define V4L2_SUBDEV_IO_PIN_SET_VALUE    (1 << 3) /* Set output value */
 
99
#define V4L2_SUBDEV_IO_PIN_ACTIVE_LOW   (1 << 4) /* ACTIVE HIGH assumed */
 
100
 
 
101
struct v4l2_subdev_io_pin_config {
 
102
        u32 flags;      /* V4L2_SUBDEV_IO_PIN_* flags for this pin's config */
 
103
        u8 pin;         /* Chip external IO pin to configure */
 
104
        u8 function;    /* Internal signal pad/function to route to IO pin */
 
105
        u8 value;       /* Initial value for pin - e.g. GPIO output value */
 
106
        u8 strength;    /* Pin drive strength */
 
107
};
 
108
 
 
109
/*
 
110
   s_io_pin_config: configure one or more chip I/O pins for chips that
 
111
        multiplex different internal signal pads out to IO pins.  This function
 
112
        takes a pointer to an array of 'n' pin configuration entries, one for
 
113
        each pin being configured.  This function could be called at times
 
114
        other than just subdevice initialization.
85
115
 
86
116
   init: initialize the sensor registors to some sort of reasonable default
87
117
        values. Do not use for new drivers and should be removed in existing
96
126
 
97
127
   s_gpio: set GPIO pins. Very simple right now, might need to be extended with
98
128
        a direction argument if needed.
 
129
 
 
130
   s_power: puts subdevice in power saving mode (on == 0) or normal operation
 
131
        mode (on == 1).
 
132
 
 
133
   interrupt_service_routine: Called by the bridge chip's interrupt service
 
134
        handler, when an interrupt status has be raised due to this subdev,
 
135
        so that this subdev can handle the details.  It may schedule work to be
 
136
        performed later.  It must not sleep.  *Called from an IRQ context*.
99
137
 */
100
138
struct v4l2_subdev_core_ops {
101
139
        int (*g_chip_ident)(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip);
102
140
        int (*log_status)(struct v4l2_subdev *sd);
103
 
        int (*s_config)(struct v4l2_subdev *sd, int irq, void *platform_data);
 
141
        int (*s_io_pin_config)(struct v4l2_subdev *sd, size_t n,
 
142
                                      struct v4l2_subdev_io_pin_config *pincfg);
104
143
        int (*init)(struct v4l2_subdev *sd, u32 val);
105
144
        int (*load_fw)(struct v4l2_subdev *sd);
106
145
        int (*reset)(struct v4l2_subdev *sd, u32 val);
118
157
        int (*g_register)(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg);
119
158
        int (*s_register)(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg);
120
159
#endif
 
160
        int (*s_power)(struct v4l2_subdev *sd, int on);
 
161
        int (*interrupt_service_routine)(struct v4l2_subdev *sd,
 
162
                                                u32 status, bool *handled);
121
163
};
122
164
 
123
165
/* s_mode: switch the tuner to a specific tuner mode. Replacement of s_radio.
127
169
   s_type_addr: sets tuner type and its I2C addr.
128
170
 
129
171
   s_config: sets tda9887 specific stuff, like port1, port2 and qss
130
 
 
131
 
   s_standby: puts tuner on powersaving state, disabling it, except for i2c.
132
172
 */
133
173
struct v4l2_subdev_tuner_ops {
134
174
        int (*s_mode)(struct v4l2_subdev *sd, enum v4l2_tuner_type);
141
181
        int (*s_modulator)(struct v4l2_subdev *sd, struct v4l2_modulator *vm);
142
182
        int (*s_type_addr)(struct v4l2_subdev *sd, struct tuner_setup *type);
143
183
        int (*s_config)(struct v4l2_subdev *sd, const struct v4l2_priv_tun_config *config);
144
 
        int (*s_standby)(struct v4l2_subdev *sd);
145
184
};
146
185
 
147
186
/* s_clock_freq: set the frequency (in Hz) of the audio clock output.
168
207
        int (*s_clock_freq)(struct v4l2_subdev *sd, u32 freq);
169
208
        int (*s_i2s_clock_freq)(struct v4l2_subdev *sd, u32 freq);
170
209
        int (*s_routing)(struct v4l2_subdev *sd, u32 input, u32 output, u32 config);
 
210
        int (*s_stream)(struct v4l2_subdev *sd, int enable);
 
211
};
 
212
 
 
213
/*
 
214
   s_std_output: set v4l2_std_id for video OUTPUT devices. This is ignored by
 
215
        video input devices.
 
216
 
 
217
   s_crystal_freq: sets the frequency of the crystal used to generate the
 
218
        clocks in Hz. An extra flags field allows device specific configuration
 
219
        regarding clock frequency dividers, etc. If not used, then set flags
 
220
        to 0. If the frequency is not supported, then -EINVAL is returned.
 
221
 
 
222
   g_input_status: get input status. Same as the status field in the v4l2_input
 
223
        struct.
 
224
 
 
225
   s_routing: see s_routing in audio_ops, except this version is for video
 
226
        devices.
 
227
 
 
228
   s_dv_preset: set dv (Digital Video) preset in the sub device. Similar to
 
229
        s_std()
 
230
 
 
231
   query_dv_preset: query dv preset in the sub device. This is similar to
 
232
        querystd()
 
233
 
 
234
   s_dv_timings(): Set custom dv timings in the sub device. This is used
 
235
        when sub device is capable of setting detailed timing information
 
236
        in the hardware to generate/detect the video signal.
 
237
 
 
238
   g_dv_timings(): Get custom dv timings in the sub device.
 
239
 
 
240
   enum_mbus_fmt: enumerate pixel formats, provided by a video data source
 
241
 
 
242
   g_mbus_fmt: get the current pixel format, provided by a video data source
 
243
 
 
244
   try_mbus_fmt: try to set a pixel format on a video data source
 
245
 
 
246
   s_mbus_fmt: set a pixel format on a video data source
 
247
 */
 
248
struct v4l2_subdev_video_ops {
 
249
        int (*s_routing)(struct v4l2_subdev *sd, u32 input, u32 output, u32 config);
 
250
        int (*s_crystal_freq)(struct v4l2_subdev *sd, u32 freq, u32 flags);
 
251
        int (*s_std_output)(struct v4l2_subdev *sd, v4l2_std_id std);
 
252
        int (*querystd)(struct v4l2_subdev *sd, v4l2_std_id *std);
 
253
        int (*g_input_status)(struct v4l2_subdev *sd, u32 *status);
 
254
        int (*s_stream)(struct v4l2_subdev *sd, int enable);
 
255
        int (*cropcap)(struct v4l2_subdev *sd, struct v4l2_cropcap *cc);
 
256
        int (*g_crop)(struct v4l2_subdev *sd, struct v4l2_crop *crop);
 
257
        int (*s_crop)(struct v4l2_subdev *sd, struct v4l2_crop *crop);
 
258
        int (*g_parm)(struct v4l2_subdev *sd, struct v4l2_streamparm *param);
 
259
        int (*s_parm)(struct v4l2_subdev *sd, struct v4l2_streamparm *param);
 
260
        int (*enum_framesizes)(struct v4l2_subdev *sd, struct v4l2_frmsizeenum *fsize);
 
261
        int (*enum_frameintervals)(struct v4l2_subdev *sd, struct v4l2_frmivalenum *fival);
 
262
        int (*enum_dv_presets) (struct v4l2_subdev *sd,
 
263
                        struct v4l2_dv_enum_preset *preset);
 
264
        int (*s_dv_preset)(struct v4l2_subdev *sd,
 
265
                        struct v4l2_dv_preset *preset);
 
266
        int (*query_dv_preset)(struct v4l2_subdev *sd,
 
267
                        struct v4l2_dv_preset *preset);
 
268
        int (*s_dv_timings)(struct v4l2_subdev *sd,
 
269
                        struct v4l2_dv_timings *timings);
 
270
        int (*g_dv_timings)(struct v4l2_subdev *sd,
 
271
                        struct v4l2_dv_timings *timings);
 
272
        int (*enum_mbus_fmt)(struct v4l2_subdev *sd, unsigned int index,
 
273
                             enum v4l2_mbus_pixelcode *code);
 
274
        int (*g_mbus_fmt)(struct v4l2_subdev *sd,
 
275
                          struct v4l2_mbus_framefmt *fmt);
 
276
        int (*try_mbus_fmt)(struct v4l2_subdev *sd,
 
277
                            struct v4l2_mbus_framefmt *fmt);
 
278
        int (*s_mbus_fmt)(struct v4l2_subdev *sd,
 
279
                          struct v4l2_mbus_framefmt *fmt);
171
280
};
172
281
 
173
282
/*
193
302
        member (to determine whether CC data from the first or second field
194
303
        should be obtained).
195
304
 
196
 
   s_std_output: set v4l2_std_id for video OUTPUT devices. This is ignored by
197
 
        video input devices.
198
 
 
199
 
  s_crystal_freq: sets the frequency of the crystal used to generate the
200
 
        clocks in Hz. An extra flags field allows device specific configuration
201
 
        regarding clock frequency dividers, etc. If not used, then set flags
202
 
        to 0. If the frequency is not supported, then -EINVAL is returned.
203
 
 
204
 
   g_input_status: get input status. Same as the status field in the v4l2_input
205
 
        struct.
206
 
 
207
 
   s_routing: see s_routing in audio_ops, except this version is for video
208
 
        devices.
 
305
   s_raw_fmt: setup the video encoder/decoder for raw VBI.
 
306
 
 
307
   g_sliced_fmt: retrieve the current sliced VBI settings.
 
308
 
 
309
   s_sliced_fmt: setup the sliced VBI settings.
209
310
 */
210
 
struct v4l2_subdev_video_ops {
211
 
        int (*s_routing)(struct v4l2_subdev *sd, u32 input, u32 output, u32 config);
212
 
        int (*s_crystal_freq)(struct v4l2_subdev *sd, u32 freq, u32 flags);
 
311
struct v4l2_subdev_vbi_ops {
213
312
        int (*decode_vbi_line)(struct v4l2_subdev *sd, struct v4l2_decode_vbi_line *vbi_line);
214
313
        int (*s_vbi_data)(struct v4l2_subdev *sd, const struct v4l2_sliced_vbi_data *vbi_data);
215
314
        int (*g_vbi_data)(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_data *vbi_data);
216
315
        int (*g_sliced_vbi_cap)(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_cap *cap);
217
 
        int (*s_std_output)(struct v4l2_subdev *sd, v4l2_std_id std);
218
 
        int (*querystd)(struct v4l2_subdev *sd, v4l2_std_id *std);
219
 
        int (*g_input_status)(struct v4l2_subdev *sd, u32 *status);
220
 
        int (*s_stream)(struct v4l2_subdev *sd, int enable);
221
 
        int (*enum_fmt)(struct v4l2_subdev *sd, struct v4l2_fmtdesc *fmtdesc);
222
 
        int (*g_fmt)(struct v4l2_subdev *sd, struct v4l2_format *fmt);
223
 
        int (*try_fmt)(struct v4l2_subdev *sd, struct v4l2_format *fmt);
224
 
        int (*s_fmt)(struct v4l2_subdev *sd, struct v4l2_format *fmt);
225
 
        int (*cropcap)(struct v4l2_subdev *sd, struct v4l2_cropcap *cc);
226
 
        int (*g_crop)(struct v4l2_subdev *sd, struct v4l2_crop *crop);
227
 
        int (*s_crop)(struct v4l2_subdev *sd, struct v4l2_crop *crop);
228
 
        int (*g_parm)(struct v4l2_subdev *sd, struct v4l2_streamparm *param);
229
 
        int (*s_parm)(struct v4l2_subdev *sd, struct v4l2_streamparm *param);
230
 
        int (*enum_framesizes)(struct v4l2_subdev *sd, struct v4l2_frmsizeenum *fsize);
231
 
        int (*enum_frameintervals)(struct v4l2_subdev *sd, struct v4l2_frmivalenum *fival);
 
316
        int (*s_raw_fmt)(struct v4l2_subdev *sd, struct v4l2_vbi_format *fmt);
 
317
        int (*g_sliced_fmt)(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *fmt);
 
318
        int (*s_sliced_fmt)(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *fmt);
 
319
};
 
320
 
 
321
/**
 
322
 * struct v4l2_subdev_sensor_ops - v4l2-subdev sensor operations
 
323
 * @g_skip_top_lines: number of lines at the top of the image to be skipped.
 
324
 *                    This is needed for some sensors, which always corrupt
 
325
 *                    several top lines of the output image, or which send their
 
326
 *                    metadata in them.
 
327
 */
 
328
struct v4l2_subdev_sensor_ops {
 
329
        int (*g_skip_top_lines)(struct v4l2_subdev *sd, u32 *lines);
 
330
};
 
331
 
 
332
/*
 
333
   [rt]x_g_parameters: Get the current operating parameters and state of the
 
334
        the IR receiver or transmitter.
 
335
 
 
336
   [rt]x_s_parameters: Set the current operating parameters and state of the
 
337
        the IR receiver or transmitter.  It is recommended to call
 
338
        [rt]x_g_parameters first to fill out the current state, and only change
 
339
        the fields that need to be changed.  Upon return, the actual device
 
340
        operating parameters and state will be returned.  Note that hardware
 
341
        limitations may prevent the actual settings from matching the requested
 
342
        settings - e.g. an actual carrier setting of 35,904 Hz when 36,000 Hz
 
343
        was requested.  An exception is when the shutdown parameter is true.
 
344
        The last used operational parameters will be returned, but the actual
 
345
        state of the hardware be different to minimize power consumption and
 
346
        processing when shutdown is true.
 
347
 
 
348
   rx_read: Reads received codes or pulse width data.
 
349
        The semantics are similar to a non-blocking read() call.
 
350
 
 
351
   tx_write: Writes codes or pulse width data for transmission.
 
352
        The semantics are similar to a non-blocking write() call.
 
353
 */
 
354
 
 
355
enum v4l2_subdev_ir_mode {
 
356
        V4L2_SUBDEV_IR_MODE_PULSE_WIDTH, /* uses struct ir_raw_event records */
 
357
};
 
358
 
 
359
struct v4l2_subdev_ir_parameters {
 
360
        /* Either Rx or Tx */
 
361
        unsigned int bytes_per_data_element; /* of data in read or write call */
 
362
        enum v4l2_subdev_ir_mode mode;
 
363
 
 
364
        bool enable;
 
365
        bool interrupt_enable;
 
366
        bool shutdown; /* true: set hardware to low/no power, false: normal */
 
367
 
 
368
        bool modulation;           /* true: uses carrier, false: baseband */
 
369
        u32 max_pulse_width;       /* ns,      valid only for baseband signal */
 
370
        unsigned int carrier_freq; /* Hz,      valid only for modulated signal*/
 
371
        unsigned int duty_cycle;   /* percent, valid only for modulated signal*/
 
372
        bool invert_level;         /* invert signal level */
 
373
 
 
374
        /* Tx only */
 
375
        bool invert_carrier_sense; /* Send 0/space as a carrier burst */
 
376
 
 
377
        /* Rx only */
 
378
        u32 noise_filter_min_width;       /* ns, min time of a valid pulse */
 
379
        unsigned int carrier_range_lower; /* Hz, valid only for modulated sig */
 
380
        unsigned int carrier_range_upper; /* Hz, valid only for modulated sig */
 
381
        u32 resolution;                   /* ns */
 
382
};
 
383
 
 
384
struct v4l2_subdev_ir_ops {
 
385
        /* Receiver */
 
386
        int (*rx_read)(struct v4l2_subdev *sd, u8 *buf, size_t count,
 
387
                                ssize_t *num);
 
388
 
 
389
        int (*rx_g_parameters)(struct v4l2_subdev *sd,
 
390
                                struct v4l2_subdev_ir_parameters *params);
 
391
        int (*rx_s_parameters)(struct v4l2_subdev *sd,
 
392
                                struct v4l2_subdev_ir_parameters *params);
 
393
 
 
394
        /* Transmitter */
 
395
        int (*tx_write)(struct v4l2_subdev *sd, u8 *buf, size_t count,
 
396
                                ssize_t *num);
 
397
 
 
398
        int (*tx_g_parameters)(struct v4l2_subdev *sd,
 
399
                                struct v4l2_subdev_ir_parameters *params);
 
400
        int (*tx_s_parameters)(struct v4l2_subdev *sd,
 
401
                                struct v4l2_subdev_ir_parameters *params);
232
402
};
233
403
 
234
404
struct v4l2_subdev_ops {
235
 
        const struct v4l2_subdev_core_ops  *core;
236
 
        const struct v4l2_subdev_tuner_ops *tuner;
237
 
        const struct v4l2_subdev_audio_ops *audio;
238
 
        const struct v4l2_subdev_video_ops *video;
 
405
        const struct v4l2_subdev_core_ops       *core;
 
406
        const struct v4l2_subdev_tuner_ops      *tuner;
 
407
        const struct v4l2_subdev_audio_ops      *audio;
 
408
        const struct v4l2_subdev_video_ops      *video;
 
409
        const struct v4l2_subdev_vbi_ops        *vbi;
 
410
        const struct v4l2_subdev_ir_ops         *ir;
 
411
        const struct v4l2_subdev_sensor_ops     *sensor;
 
412
};
 
413
 
 
414
/*
 
415
 * Internal ops. Never call this from drivers, only the v4l2 framework can call
 
416
 * these ops.
 
417
 *
 
418
 * registered: called when this subdev is registered. When called the v4l2_dev
 
419
 *      field is set to the correct v4l2_device.
 
420
 *
 
421
 * unregistered: called when this subdev is unregistered. When called the
 
422
 *      v4l2_dev field is still set to the correct v4l2_device.
 
423
 */
 
424
struct v4l2_subdev_internal_ops {
 
425
        int (*registered)(struct v4l2_subdev *sd);
 
426
        void (*unregistered)(struct v4l2_subdev *sd);
239
427
};
240
428
 
241
429
#define V4L2_SUBDEV_NAME_SIZE 32
242
430
 
243
431
/* Set this flag if this subdev is a i2c device. */
244
432
#define V4L2_SUBDEV_FL_IS_I2C (1U << 0)
 
433
/* Set this flag if this subdev is a spi device. */
 
434
#define V4L2_SUBDEV_FL_IS_SPI (1U << 1)
245
435
 
246
436
/* Each instance of a subdev driver should create this struct, either
247
437
   stand-alone or embedded in a larger struct.
252
442
        u32 flags;
253
443
        struct v4l2_device *v4l2_dev;
254
444
        const struct v4l2_subdev_ops *ops;
 
445
        /* Never call these internal ops from within a driver! */
 
446
        const struct v4l2_subdev_internal_ops *internal_ops;
 
447
        /* The control handler of this subdev. May be NULL. */
 
448
        struct v4l2_ctrl_handler *ctrl_handler;
255
449
        /* name must be unique */
256
450
        char name[V4L2_SUBDEV_NAME_SIZE];
257
451
        /* can be used to group similar subdevs, value is driver-specific */
258
452
        u32 grp_id;
259
453
        /* pointer to private data */
260
 
        void *priv;
 
454
        void *dev_priv;
 
455
        void *host_priv;
261
456
};
262
457
 
263
458
static inline void v4l2_set_subdevdata(struct v4l2_subdev *sd, void *p)
264
459
{
265
 
        sd->priv = p;
 
460
        sd->dev_priv = p;
266
461
}
267
462
 
268
463
static inline void *v4l2_get_subdevdata(const struct v4l2_subdev *sd)
269
464
{
270
 
        return sd->priv;
 
465
        return sd->dev_priv;
 
466
}
 
467
 
 
468
static inline void v4l2_set_subdev_hostdata(struct v4l2_subdev *sd, void *p)
 
469
{
 
470
        sd->host_priv = p;
 
471
}
 
472
 
 
473
static inline void *v4l2_get_subdev_hostdata(const struct v4l2_subdev *sd)
 
474
{
 
475
        return sd->host_priv;
271
476
}
272
477
 
273
478
static inline void v4l2_subdev_init(struct v4l2_subdev *sd,
281
486
        sd->flags = 0;
282
487
        sd->name[0] = '\0';
283
488
        sd->grp_id = 0;
284
 
        sd->priv = NULL;
 
489
        sd->dev_priv = NULL;
 
490
        sd->host_priv = NULL;
285
491
}
286
492
 
287
493
/* Call an ops of a v4l2_subdev, doing the right checks against
290
496
   Example: err = v4l2_subdev_call(sd, core, g_chip_ident, &chip);
291
497
 */
292
498
#define v4l2_subdev_call(sd, o, f, args...)                             \
293
 
        (!(sd) ? -ENODEV : (((sd) && (sd)->ops->o && (sd)->ops->o->f) ? \
 
499
        (!(sd) ? -ENODEV : (((sd)->ops->o && (sd)->ops->o->f) ? \
294
500
                (sd)->ops->o->f((sd) , ##args) : -ENOIOCTLCMD))
295
501
 
296
502
/* Send a notification to v4l2_device. */