]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - drivers/media/video/omap/camera_core.h
02ed5bef8349306ecbd702933219a9cc22ceb32c
[linux-2.6-omap-h63xx.git] / drivers / media / video / omap / camera_core.h
1 /*
2  *  drivers/media/video/omap/camera_core.h
3  *
4  * Copyright (C) 2004 Texas Instruments, Inc.
5  *
6  * This package is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
11  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
12  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13  */
14
15 #ifndef CAMERA_CORE__H
16 #define CAMERA_CORE__H
17
18 struct camera_fh;
19
20 #include <asm/scatterlist.h>
21 #include <media/videobuf-dma-sg.h>
22 #include <media/v4l2-int-device.h>
23
24 struct camera_device;
25 typedef void (*dma_callback_t)(void *arg1, void *arg2);
26
27 struct sgdma_state {
28         const struct scatterlist *sglist;
29         int sglen;              /* number of sglist entries */
30         int next_sglist;        /* index of next sglist entry to process */
31         int queued_sglist;      /* number of sglist entries queued for DMA */
32         unsigned long csr;      /* DMA return code */
33         dma_callback_t callback;
34         void *arg;
35 };
36
37 /* NUM_SG_DMA is the number of scatter-gather DMA transfers that can be queued.
38  */
39 #define NUM_SG_DMA VIDEO_MAX_FRAME+2
40
41 /* per-device data structure */
42 struct camera_device {
43         struct device *dev;
44         struct video_device *vfd;
45
46         spinlock_t overlay_lock;        /* spinlock for overlay DMA counter */
47         int overlay_cnt;                /* count of queued overlay DMA xfers */
48         struct scatterlist overlay_sglist;
49         unsigned long overlay_base_phys;
50         unsigned long overlay_base;
51         unsigned long overlay_size;
52
53         spinlock_t vbq_lock;            /* spinlock for videobuf queues */
54         struct videobuf_queue_ops vbq_ops;      /* videobuf queue operations */
55         unsigned long field_count;      /* field counter for videobuf_buffer */
56
57         /* scatter-gather DMA management */
58         spinlock_t sg_lock;
59         int free_sgdma; /* number of free sg dma slots */
60         int next_sgdma; /* index of next sg dma slot to use */
61         struct sgdma_state sgdma[NUM_SG_DMA];
62         char in_use;
63
64         /* The img_lock is used to serialize access to the image parameters for
65          * overlay and capture.  Need to use spin_lock_irq when writing to the
66          * reading, streaming, and previewing parameters.  A regular spin_lock
67          * will suffice for all other cases.
68          */
69         spinlock_t img_lock;
70
71         /* We allow reading from at most one filehandle at a time.
72          * non-NULL means reading is in progress.
73          */
74         struct camera_fh *reading;
75         /* We allow streaming from at most one filehandle at a time.
76          * non-NULL means streaming is in progress.
77          */
78         struct camera_fh *streaming;
79         /* We allow previewing from at most one filehandle at a time.
80          * non-NULL means previewing is in progress.
81          */
82         struct camera_fh *previewing;
83
84         /*
85          * Sensor interface parameters: interface type, CC_CTRL
86          * register value and interface specific data.
87          */
88         int if_type;
89         union {
90                 struct parallel {
91                         u32 xclk;
92                 } bt656;
93         } if_u;
94         /* Pointer to the sensor interface ops */
95         struct v4l2_int_device *sdev;
96
97         /* Pointer to the camera interface hardware ops */
98         struct camera_hardware *cam_hardware;
99         void *hardware_data;
100
101         /* pix defines the size and pixel format of the image captured by the
102          * sensor.  This also defines the size of the framebuffers.  The
103          * same pool of framebuffers is used for video capture and video
104          * overlay.  These parameters are set/queried by the
105          * VIDIOC_S_FMT/VIDIOC_G_FMT ioctls with a CAPTURE buffer type.
106          */
107         struct v4l2_pix_format pix;
108
109         /* crop defines the size and offset of the video overlay source window
110          * within the framebuffer.  These parameters are set/queried by the
111          * VIDIOC_S_CROP/VIDIOC_G_CROP ioctls with an OVERLAY buffer type.
112          * The cropping rectangle allows a subset of the captured image to be
113          * previewed.  It only affects the portion of the image previewed, not
114          * captured; the entire camera image is always captured.
115          */
116         struct v4l2_rect crop;
117
118         /* win defines the size and offset of the video overlay target window
119          * within the video display.  These parameters are set/queried by the
120          * VIDIOC_S_FMT/VIDIOC_G_FMT ioctls with an OVERLAY buffer type.
121          */
122         struct v4l2_window win;
123
124         /* fbuf reflects the size of the video display.  It is queried with the
125          * VIDIOC_G_FBUF ioctl.  The size of the video display cannot be
126          * changed with the VIDIOC_S_FBUF ioctl.
127          */
128         struct v4l2_framebuffer fbuf;
129
130         /* end of generic stuff, the above should be common to all omaps */
131
132         /* note, 2420 uses videobuf to do caprure, it is more memory efficient
133            we need 1710 and 2420 do capture in the same way */
134         /* Variables to store the capture state */
135         /* Wait till DMA is completed */
136         wait_queue_head_t new_video_frame;
137         char capture_completed;
138         char capture_started;
139         spinlock_t capture_lock;
140         struct scatterlist capture_sglist;
141         unsigned long capture_base;
142         unsigned long capture_base_phys;
143
144         char active;
145 };
146
147 /* per-filehandle data structure */
148 struct camera_fh {
149         struct camera_device *cam;
150         enum v4l2_buf_type type;
151         struct videobuf_queue vbq;
152 };
153
154 #define CAM_NAME "omap_camera"
155
156 #endif /* CAMERA_CORE__H */