~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#ifndef _V4L2_SUBDEV_H
22
22
#define _V4L2_SUBDEV_H
23
23
 
 
24
#include <linux/v4l2-subdev.h>
 
25
#include <media/media-entity.h>
24
26
#include <media/v4l2-common.h>
 
27
#include <media/v4l2-dev.h>
 
28
#include <media/v4l2-fh.h>
25
29
#include <media/v4l2-mediabus.h>
26
30
 
27
31
/* generic v4l2_device notify callback notification values */
36
40
 
37
41
struct v4l2_device;
38
42
struct v4l2_ctrl_handler;
 
43
struct v4l2_event_subscription;
 
44
struct v4l2_fh;
39
45
struct v4l2_subdev;
 
46
struct v4l2_subdev_fh;
40
47
struct tuner_setup;
41
48
 
42
49
/* decode_vbi_line */
160
167
        int (*s_power)(struct v4l2_subdev *sd, int on);
161
168
        int (*interrupt_service_routine)(struct v4l2_subdev *sd,
162
169
                                                u32 status, bool *handled);
 
170
        int (*subscribe_event)(struct v4l2_subdev *sd, struct v4l2_fh *fh,
 
171
                               struct v4l2_event_subscription *sub);
 
172
        int (*unsubscribe_event)(struct v4l2_subdev *sd, struct v4l2_fh *fh,
 
173
                                 struct v4l2_event_subscription *sub);
163
174
};
164
175
 
165
 
/* s_mode: switch the tuner to a specific tuner mode. Replacement of s_radio.
166
 
 
167
 
   s_radio: v4l device was opened in Radio mode, to be replaced by s_mode.
 
176
/* s_radio: v4l device was opened in radio mode.
 
177
 
 
178
   g_frequency: freq->type must be filled in. Normally done by video_ioctl2
 
179
        or the bridge driver.
 
180
 
 
181
   g_tuner:
 
182
   s_tuner: vt->type must be filled in. Normally done by video_ioctl2 or the
 
183
        bridge driver.
168
184
 
169
185
   s_type_addr: sets tuner type and its I2C addr.
170
186
 
171
187
   s_config: sets tda9887 specific stuff, like port1, port2 and qss
172
188
 */
173
189
struct v4l2_subdev_tuner_ops {
174
 
        int (*s_mode)(struct v4l2_subdev *sd, enum v4l2_tuner_type);
175
190
        int (*s_radio)(struct v4l2_subdev *sd);
176
191
        int (*s_frequency)(struct v4l2_subdev *sd, struct v4l2_frequency *freq);
177
192
        int (*g_frequency)(struct v4l2_subdev *sd, struct v4l2_frequency *freq);
257
272
        int (*s_crop)(struct v4l2_subdev *sd, struct v4l2_crop *crop);
258
273
        int (*g_parm)(struct v4l2_subdev *sd, struct v4l2_streamparm *param);
259
274
        int (*s_parm)(struct v4l2_subdev *sd, struct v4l2_streamparm *param);
 
275
        int (*g_frame_interval)(struct v4l2_subdev *sd,
 
276
                                struct v4l2_subdev_frame_interval *interval);
 
277
        int (*s_frame_interval)(struct v4l2_subdev *sd,
 
278
                                struct v4l2_subdev_frame_interval *interval);
260
279
        int (*enum_framesizes)(struct v4l2_subdev *sd, struct v4l2_frmsizeenum *fsize);
261
280
        int (*enum_frameintervals)(struct v4l2_subdev *sd, struct v4l2_frmivalenum *fival);
262
281
        int (*enum_dv_presets) (struct v4l2_subdev *sd,
271
290
                        struct v4l2_dv_timings *timings);
272
291
        int (*enum_mbus_fmt)(struct v4l2_subdev *sd, unsigned int index,
273
292
                             enum v4l2_mbus_pixelcode *code);
 
293
        int (*enum_mbus_fsizes)(struct v4l2_subdev *sd,
 
294
                             struct v4l2_frmsizeenum *fsize);
274
295
        int (*g_mbus_fmt)(struct v4l2_subdev *sd,
275
296
                          struct v4l2_mbus_framefmt *fmt);
276
297
        int (*try_mbus_fmt)(struct v4l2_subdev *sd,
324
345
 *                    This is needed for some sensors, which always corrupt
325
346
 *                    several top lines of the output image, or which send their
326
347
 *                    metadata in them.
 
348
 * @g_skip_frames: number of frames to skip at stream start. This is needed for
 
349
 *                 buggy sensors that generate faulty frames when they are
 
350
 *                 turned on.
327
351
 */
328
352
struct v4l2_subdev_sensor_ops {
329
353
        int (*g_skip_top_lines)(struct v4l2_subdev *sd, u32 *lines);
 
354
        int (*g_skip_frames)(struct v4l2_subdev *sd, u32 *frames);
330
355
};
331
356
 
332
357
/*
401
426
                                struct v4l2_subdev_ir_parameters *params);
402
427
};
403
428
 
 
429
struct v4l2_subdev_pad_ops {
 
430
        int (*enum_mbus_code)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
 
431
                              struct v4l2_subdev_mbus_code_enum *code);
 
432
        int (*enum_frame_size)(struct v4l2_subdev *sd,
 
433
                               struct v4l2_subdev_fh *fh,
 
434
                               struct v4l2_subdev_frame_size_enum *fse);
 
435
        int (*enum_frame_interval)(struct v4l2_subdev *sd,
 
436
                                   struct v4l2_subdev_fh *fh,
 
437
                                   struct v4l2_subdev_frame_interval_enum *fie);
 
438
        int (*get_fmt)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
 
439
                       struct v4l2_subdev_format *format);
 
440
        int (*set_fmt)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
 
441
                       struct v4l2_subdev_format *format);
 
442
        int (*set_crop)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
 
443
                       struct v4l2_subdev_crop *crop);
 
444
        int (*get_crop)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
 
445
                       struct v4l2_subdev_crop *crop);
 
446
};
 
447
 
404
448
struct v4l2_subdev_ops {
405
449
        const struct v4l2_subdev_core_ops       *core;
406
450
        const struct v4l2_subdev_tuner_ops      *tuner;
409
453
        const struct v4l2_subdev_vbi_ops        *vbi;
410
454
        const struct v4l2_subdev_ir_ops         *ir;
411
455
        const struct v4l2_subdev_sensor_ops     *sensor;
 
456
        const struct v4l2_subdev_pad_ops        *pad;
412
457
};
413
458
 
414
459
/*
420
465
 *
421
466
 * unregistered: called when this subdev is unregistered. When called the
422
467
 *      v4l2_dev field is still set to the correct v4l2_device.
 
468
 *
 
469
 * open: called when the subdev device node is opened by an application.
 
470
 *
 
471
 * close: called when the subdev device node is closed.
423
472
 */
424
473
struct v4l2_subdev_internal_ops {
425
474
        int (*registered)(struct v4l2_subdev *sd);
426
475
        void (*unregistered)(struct v4l2_subdev *sd);
 
476
        int (*open)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh);
 
477
        int (*close)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh);
427
478
};
428
479
 
429
480
#define V4L2_SUBDEV_NAME_SIZE 32
430
481
 
431
482
/* Set this flag if this subdev is a i2c device. */
432
 
#define V4L2_SUBDEV_FL_IS_I2C (1U << 0)
 
483
#define V4L2_SUBDEV_FL_IS_I2C                   (1U << 0)
433
484
/* Set this flag if this subdev is a spi device. */
434
 
#define V4L2_SUBDEV_FL_IS_SPI (1U << 1)
 
485
#define V4L2_SUBDEV_FL_IS_SPI                   (1U << 1)
 
486
/* Set this flag if this subdev needs a device node. */
 
487
#define V4L2_SUBDEV_FL_HAS_DEVNODE              (1U << 2)
 
488
/* Set this flag if this subdev generates events. */
 
489
#define V4L2_SUBDEV_FL_HAS_EVENTS               (1U << 3)
435
490
 
436
491
/* Each instance of a subdev driver should create this struct, either
437
492
   stand-alone or embedded in a larger struct.
438
493
 */
439
494
struct v4l2_subdev {
 
495
#if defined(CONFIG_MEDIA_CONTROLLER)
 
496
        struct media_entity entity;
 
497
#endif
440
498
        struct list_head list;
441
499
        struct module *owner;
442
500
        u32 flags;
453
511
        /* pointer to private data */
454
512
        void *dev_priv;
455
513
        void *host_priv;
456
 
};
 
514
        /* subdev device node */
 
515
        struct video_device devnode;
 
516
        /* number of events to be allocated on open */
 
517
        unsigned int nevents;
 
518
};
 
519
 
 
520
#define media_entity_to_v4l2_subdev(ent) \
 
521
        container_of(ent, struct v4l2_subdev, entity)
 
522
#define vdev_to_v4l2_subdev(vdev) \
 
523
        container_of(vdev, struct v4l2_subdev, devnode)
 
524
 
 
525
/*
 
526
 * Used for storing subdev information per file handle
 
527
 */
 
528
struct v4l2_subdev_fh {
 
529
        struct v4l2_fh vfh;
 
530
#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
 
531
        struct v4l2_mbus_framefmt *try_fmt;
 
532
        struct v4l2_rect *try_crop;
 
533
#endif
 
534
};
 
535
 
 
536
#define to_v4l2_subdev_fh(fh)   \
 
537
        container_of(fh, struct v4l2_subdev_fh, vfh)
 
538
 
 
539
#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
 
540
static inline struct v4l2_mbus_framefmt *
 
541
v4l2_subdev_get_try_format(struct v4l2_subdev_fh *fh, unsigned int pad)
 
542
{
 
543
        return &fh->try_fmt[pad];
 
544
}
 
545
 
 
546
static inline struct v4l2_rect *
 
547
v4l2_subdev_get_try_crop(struct v4l2_subdev_fh *fh, unsigned int pad)
 
548
{
 
549
        return &fh->try_crop[pad];
 
550
}
 
551
#endif
 
552
 
 
553
extern const struct v4l2_file_operations v4l2_subdev_fops;
457
554
 
458
555
static inline void v4l2_set_subdevdata(struct v4l2_subdev *sd, void *p)
459
556
{
475
572
        return sd->host_priv;
476
573
}
477
574
 
478
 
static inline void v4l2_subdev_init(struct v4l2_subdev *sd,
479
 
                                        const struct v4l2_subdev_ops *ops)
480
 
{
481
 
        INIT_LIST_HEAD(&sd->list);
482
 
        /* ops->core MUST be set */
483
 
        BUG_ON(!ops || !ops->core);
484
 
        sd->ops = ops;
485
 
        sd->v4l2_dev = NULL;
486
 
        sd->flags = 0;
487
 
        sd->name[0] = '\0';
488
 
        sd->grp_id = 0;
489
 
        sd->dev_priv = NULL;
490
 
        sd->host_priv = NULL;
491
 
}
 
575
void v4l2_subdev_init(struct v4l2_subdev *sd,
 
576
                      const struct v4l2_subdev_ops *ops);
492
577
 
493
578
/* Call an ops of a v4l2_subdev, doing the right checks against
494
579
   NULL pointers.