⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 camera_core.h

📁 Linux Kernel 2.6.9 for OMAP1710
💻 H
字号:
/*
 *  linux/drivers/media/video/omap/camera_core.h
 *
 * Copyright (C) 2004 Texas Instruments Inc
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef CAMERA_CORE__H
#define CAMERA_CORE__H

struct camera_fh;

#define STREAMING
#ifdef STREAMING
#include <media/video-buf.h>
#include <asm/scatterlist.h>

struct camera_device;
typedef void (*dma_callback_t)(struct camera_device *cam, void *arg);

struct sgdma_state {
        const struct scatterlist *sglist;
        int sglen;              /* number of sglist entries */
        int next_sglist;        /* index of next sglist entry to process */
        int queued_sglist;      /* number of sglist entries queued for DMA */
        unsigned long csr;      /* DMA return code */
        dma_callback_t callback;
        void *arg;
};

/* NUM_CAMDMA_CHANNELS is the number of logical channels provided by the camera
 * DMA controller.
 */
#define NUM_CAMDMA_CHANNELS 2

/* NUM_SG_DMA is the number of scatter-gather DMA transfers that can be queued.
 */
#define NUM_SG_DMA VIDEO_MAX_FRAME+2

struct camdma_state {
	dma_callback_t callback;
	void *arg;
};
#endif /* STREAMING */

/* per-device data structure */
struct camera_device {
	struct device dev;
	struct video_device *vfd;
	
	/* frequncy (in Hz) of camera interface functional clock (ocp_clk) */
	unsigned long ocp_clk; 
	unsigned long iobase_phys;

	/* The img_lock is used to serialize access to the image parameters for 
	 * overlay and capture.  Need to use spin_lock_irq when writing to the 
	 * reading, streaming, and previewing parameters.  A regular spin_lock 
	 * will suffice for all other cases.
	 */
	spinlock_t img_lock;
 
 	/* We allow reading from at most one filehandle at a time.
 	 * non-NULL means reading is in progress.
 	 */
 	struct camera_fh *reading;
 	/* We allow streaming from at most one filehandle at a time.  
 	 * non-NULL means streaming is in progress.
 	 */
	struct camera_fh *streaming;
	/* We allow previewing from at most one filehandle at a time.  
	 * non-NULL means previewing is in progress.
	 */
	struct camera_fh *previewing;

	/* frequency (in Hz) of camera interface xclk output */
	unsigned long xclk;

	/* pix defines the size and pixel format of the image captured by the 
	 * sensor.  This also defines the size of the framebuffers.  The 
	 * same pool of framebuffers is used for video capture and video 
	 * overlay.  These parameters are set/queried by the 
	 * VIDIOC_S_FMT/VIDIOC_G_FMT ioctls with a CAPTURE buffer type.
	 */
	struct v4l2_pix_format pix;

	/* crop defines the size and offset of the video overlay source window 
	 * within the framebuffer.  These parameters are set/queried by the 
	 * VIDIOC_S_CROP/VIDIOC_G_CROP ioctls with an OVERLAY buffer type.  
	 * The cropping rectangle allows a subset of the captured image to be 
	 * previewed.  It only affects the portion of the image previewed, not 
	 * captured; the entire camera image is always captured.
	 */
	struct v4l2_rect crop;

	/* win defines the size and offset of the video overlay target window 
	 * within the video display.  These parameters are set/queried by the 
	 * VIDIOC_S_FMT/VIDIOC_G_FMT ioctls with an OVERLAY buffer type.
	 */
	struct v4l2_window win;

	/* fbuf reflects the size of the video display.  It is queried with the 
	 * VIDIOC_G_FBUF ioctl.  The size of the video display cannot be 
	 * changed with the VIDIOC_S_FBUF ioctl.
	 */
	struct v4l2_framebuffer fbuf;

	/* overlay is enabled = 1 disabled = 0; Initialised to zero */
	char overlay;

	/* capture parameters (frame rate, number of buffers) */
	struct v4l2_captureparm cparm;

	/* This is the frame period actually requested by the user. */
	struct v4l2_fract nominal_timeperframe;
	
	/* Wait till DMA is completed */
	wait_queue_head_t new_video_frame;

	/* Variables to store the capture state */
	char capture_completed;
	char capture_started;
	
	/* Capture buffer */
	void *read_buf;
	void *temp_buf;
	unsigned int read_buf_size;
	spinlock_t capture_lock;
	struct scatterlist capture_sglist;
	unsigned long capture_base;
	unsigned long capture_base_phys;

	/* Pointer to the sensor interface structuure */
	struct camera_sensor *cam_sensor;
	
	/* Pointer to the camera driver interface */
	struct camera_interface *cam_if;

        spinlock_t overlay_lock;        /* spinlock for overlay DMA counter */
        int overlay_cnt;                /* count of queued overlay DMA xfers */
        struct scatterlist overlay_sglist;
	unsigned long overlay_base_phys;
	unsigned long overlay_base;
        unsigned long overlay_size;

        spinlock_t vbq_lock;            /* spinlock for videobuf queues */
        struct videobuf_queue_ops vbq_ops;      /* videobuf queue operations */
        unsigned long field_count;      /* field counter for videobuf_buffer */

        /* scatter-gather DMA management */
        spinlock_t sg_lock;
        int free_sgdma; /* number of free sg dma slots */
        int next_sgdma; /* index of next sg dma slot to use */
        struct sgdma_state sgdma[NUM_SG_DMA];
	/* dma related stuff */
	spinlock_t dma_lock;
	int free_dmach;
	int next_dmach;
	struct camdma_state camdma[2];
};

/* per-filehandle data structure */
struct camera_fh {
	struct camera_device *cam;
	enum v4l2_buf_type type;
#ifdef STREAMING
        struct videobuf_queue vbq;
#endif
};

#define CAM_NAME "omap-camera"

enum image_size image_find_size(unsigned int width, unsigned int height);

#endif /* CAMERA_CORE__H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -