]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - drivers/media/video/omap/camera_core.h
cffc263b3d65191513a7e4463cf92e820f74d4a0
[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 <media/video-buf.h>
21 #include <asm/scatterlist.h>
22
23 struct camera_device;
24 typedef void (*dma_callback_t)(void *arg1, void *arg2);
25
26 struct sgdma_state {
27         const struct scatterlist *sglist;
28         int sglen;              /* number of sglist entries */
29         int next_sglist;        /* index of next sglist entry to process */
30         int queued_sglist;      /* number of sglist entries queued for DMA */
31         unsigned long csr;      /* DMA return code */
32         dma_callback_t callback;
33         void *arg;
34 };
35
36 /* NUM_SG_DMA is the number of scatter-gather DMA transfers that can be queued.
37  */
38 #define NUM_SG_DMA VIDEO_MAX_FRAME+2
39  
40 /* per-device data structure */
41 struct camera_device {
42         struct device dev;
43         struct video_device *vfd;
44         
45         spinlock_t overlay_lock;        /* spinlock for overlay DMA counter */
46         int overlay_cnt;                /* count of queued overlay DMA xfers */
47         struct scatterlist overlay_sglist;
48         unsigned long overlay_base_phys;
49         unsigned long overlay_base;
50         unsigned long overlay_size;
51
52         spinlock_t vbq_lock;            /* spinlock for videobuf queues */
53         struct videobuf_queue_ops vbq_ops;      /* videobuf queue operations */
54         unsigned long field_count;      /* field counter for videobuf_buffer */
55
56         /* scatter-gather DMA management */
57         spinlock_t sg_lock;
58         int free_sgdma; /* number of free sg dma slots */
59         int next_sgdma; /* index of next sg dma slot to use */
60         struct sgdma_state sgdma[NUM_SG_DMA];
61         char in_use;
62
63         /* The img_lock is used to serialize access to the image parameters for 
64          * overlay and capture.  Need to use spin_lock_irq when writing to the 
65          * reading, streaming, and previewing parameters.  A regular spin_lock 
66          * will suffice for all other cases.
67          */
68         spinlock_t img_lock;
69  
70         /* We allow reading from at most one filehandle at a time.
71          * non-NULL means reading is in progress.
72          */
73         struct camera_fh *reading;
74         /* We allow streaming from at most one filehandle at a time.  
75          * non-NULL means streaming is in progress.
76          */
77         struct camera_fh *streaming;
78         /* We allow previewing from at most one filehandle at a time.  
79          * non-NULL means previewing is in progress.
80          */
81         struct camera_fh *previewing;
82
83         /* capture parameters (frame rate, number of buffers) */
84         struct v4l2_captureparm cparm;
85
86         /* This is the frame period actually requested by the user. */
87         struct v4l2_fract nominal_timeperframe;
88         
89         /* frequency (in Hz) of camera interface xclk output */
90         unsigned long xclk;
91
92         /* Pointer to the sensor interface ops */
93         struct camera_sensor *cam_sensor;
94         void *sensor_data;
95         
96         /* Pointer to the camera interface hardware ops */
97         struct camera_hardware *cam_hardware;
98         void *hardware_data;
99
100         /* pix defines the size and pixel format of the image captured by the 
101          * sensor.  This also defines the size of the framebuffers.  The 
102          * same pool of framebuffers is used for video capture and video 
103          * overlay.  These parameters are set/queried by the 
104          * VIDIOC_S_FMT/VIDIOC_G_FMT ioctls with a CAPTURE buffer type.
105          */
106         struct v4l2_pix_format pix;
107         struct v4l2_pix_format pix2;
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 */