aboutsummaryrefslogtreecommitdiff
path: root/arch/arm/mach-s3c2440/camera/qt-driver.c
blob: 0c5dd40cf2ccd5c2e1bacc9243ed3bdf4ddb47b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/*
 * SW.LEE <hitchcar@samsung.com>
 *   
 * This file is subject to the terms and conditions of the GNU General Public
 * License 2. See the file COPYING in the main directory of this archive
 * for more details.
 */

#include <linux/version.h>
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/errno.h>
#include <linux/fs.h>
#include <linux/kernel.h>
#include <linux/major.h>
#include <linux/slab.h>
#include <linux/poll.h>
#include <linux/signal.h>
#include <linux/ioport.h>
#include <linux/sched.h>
#include <linux/types.h>
#include <linux/interrupt.h>
#include <linux/kmod.h>
#include <linux/vmalloc.h>
#include <linux/init.h>
#include <asm/io.h>
#include <asm/page.h>
#include <asm/irq.h>
#include <asm/semaphore.h>
#include <linux/miscdevice.h>
                                                                                                           
//#define SW_DEBUG
                                                                                                           
#include "camif.h"
#include "videodev.h"
#include "miscdevice.h"
#include "cam_reg.h"
#include "sensor.h"
#include "userapp.h"
                                                                                                           

/************************* Sharp Zarus API **************************
* refering to Camera Driver API for SL-5000D/SL-5600 revision 1.00 
*   				April 11, 2002.
  SW.LEE <hitchcar@sec.samsung.com>
   		I want to use Sharp Camera Application. 
*
*/

#define READ_MODE_STATUS	0x1
#define READ_MODE_IMAGE		0x0
#define CAPTURE_SPEED
#define	H_FLIP	
#define V_FLIP
typedef enum sharp_readmode 
{
        IMAGE = 0, STATUS = 1,
        FASTER = 0, BETTER = 2,
        XNOFLIP = 0, XFLIP = 4,
        YNOFLIP = 0, YFLIP = 8,
        AUTOMATICFLIP = -1
} ReadMode_t;


static struct sharp_param_t {
	ReadMode_t readMode;
	char CameraStatus[4];
} sharp_param = { STATUS, {'s','m','c','A'}};


camif_param_t qt_parm = { 640,480,240,320,16,0};
	
static void setReadMode(const char *b,size_t count)
{
	int i =   *(b+2) - 48 ;
	if ( 4 == count ) {
		i = (*(b+3) - 48)  + i * 10;
	}

	//	DPRINTK(" setReadMode %s conversion value %d \n",b , i); 
	if ( i & STATUS ) { 
	//	DPRINTK(" STATUS MODE \n");
		sharp_param.readMode = i;
	}
	else  {
	//	DPRINTK(" IMAGE MODE \n");
		sharp_param.readMode = i;
	}
}




extern ssize_t camif_p_read(struct file *, char *, size_t , loff_t *);

ssize_t z_read(struct file *f, char *buf, size_t count, loff_t *pos)
{
	size_t end;

	if (sharp_param.readMode & STATUS ) {
		buf[0] = sharp_param.CameraStatus[0];
		buf[1] = sharp_param.CameraStatus[1];
		buf[2] = sharp_param.CameraStatus[2];
		buf[3] = sharp_param.CameraStatus[3];
		end = 4;
		return end;
	} 
	else {	/* Image ReadMode */
		/*
		if (( sharp_param.readMode & (BETTER|X  FLIP|YFLIP)))
			DPRINTK("  Not Supporting BETTER|XFLIP|YFLIP\n");
		*/
		return camif_p_read(f,buf,count,pos);
	}
}

static void z_config(camif_cfg_t *cfg,int x, int y)
{
	cfg->target_x = x;
	cfg->target_y = y;
	cfg->fmt = CAMIF_RGB16;
	if (camif_dynamic_open(cfg)) {
		panic(" Eror Happens \n");
	}
}


ssize_t z_write(struct file *f, const char *b, size_t c, loff_t *pos)
{
	int array[5];
	int zoom = 1;
	camif_cfg_t *cfg;

	cfg = get_camif(MINOR(f->f_dentry->d_inode->i_rdev));
//	DPRINTK(" param %s count %d \n",b, c );

	switch(*b) {
	case 'M':	
		setReadMode(b, c);
		break;
	case 'B':	/* Clear the latch flag of shutter button */
		DPRINTK("  clear latch flag of camera's shutter button\n");
		sharp_param.CameraStatus[0]='s';
		break;
	case 'Y':	/* I don't know how to set Shutter pressed */	
		DPRINTK("  set latch flag n");
		sharp_param.CameraStatus[0]='S';
		break;
	case 'S':	/* Camera Image Resolution */
	case 'R':	/* Donot support Rotation */
	DPRINTK(" param %s count %d \n",b, c );
		get_options((char *)(b+2), 5, array);
		if ( array[3] == 512 ) zoom = 2;
		z_config(cfg, array[1] * zoom , array[2] * zoom );
		camif_4fsm_start(cfg);
		break;
	case 'C':
	DPRINTK(" param %s count %d \n",b, c );
		DPRINTK("  Start the camera to capture \n");
		sharp_param.CameraStatus[2]='C';
		camif_4fsm_start(cfg);
		break;
	default:
		printk("Unexpected  param %s count %d \n",b, c );
	}

	return c;
}