comparison src/aci2/mfw/mfw_cam.c @ 3:93999a60b835

src/aci2, src/condat2: import of g23m/condat source pieces from TCS211
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 26 Sep 2016 00:29:36 +0000
parents
children
comparison
equal deleted inserted replaced
2:c41a534f33c6 3:93999a60b835
1 /*
2 +--------------------------------------------------------------------+
3 | PROJECT: MMI-Framework (8417) $Workfile:: mfw_cam.c $|
4 | $Author:: NDH $Revision:: 1 $|
5 | CREATED: 21.05.04 $Modtime:: 21.05.04 14:58 $|
6 | STATE : code |
7 +--------------------------------------------------------------------+
8
9 MODULE : MFW_CAM
10
11 PURPOSE : This module contains Camera Interface functions.
12
13 HISTORY:
14
15 Nov 29, 2005 REF: MMI-SPR-33833(OMAPS00055207)- x0035544
16 MMI making Riviera calls without using proper header files. So added appropriate header files.
17
18 Sept 15, 2005 REF: LOCOSTO-ENH-34257 - xpradipg
19 Description: Locosto: MIgration to New LCD APIs
20 Solution: Migrated to New APIs by replacing the old driver APIs with
21 corresponding New LCD APIs
22
23 Sep 13, 2005 REF: SPR 33992 xdeepadh
24 Description: Image viewer cannot open file when saved in high quality
25 Solution: The quality factor has been rearranged to support saving the images within 64KBlimit.
26
27 Aug 22 2005, xpradipg - LOCOSTO-ENH-31154
28 Description: Application to test camera
29 Solution: Implemented the camera application with following functionalities
30 preview, snapshot and image saving.
31
32 */
33
34
35 /*
36 ** Include Files
37 */
38
39 #define ENTITY_MFW
40 /* includes */
41 #include <string.h>
42
43
44 #include "typedefs.h"
45 #include "vsi.h"
46 #include "pei.h"
47 #include "custom.h"
48 #include "gsm.h"
49
50 #include "message.h" /* included for aci_cmh.h .... */
51 #include "prim.h" /* included for aci_cmh.h .... */
52 #include "aci_cmh.h" /* included for mfw_sat.h, included for MmiDummy.h, included for MmiMenu.h */
53
54
55 #include "mfw_mfw.h"
56 #include "mfw_win.h"
57 #include "mfw_cam.h"
58
59 //#include "img/img_api.h" //included for img_message.h
60 //#include "img/img_message.h"
61
62 #include "mks/mks_api.h"
63
64 //#include "r2d/lcd_messages_ti.h"
65 //#include "r2d/lcd_messages.h"
66 #include "r2d/r2d.h"
67 //#include "cama/cama_cfg.h"
68 //#include "cama/cama_i.h"
69 #include "cama/camil_api.h"
70 #include "cama/camil_i.h"
71 //#include "gil/gil_gpf.h"
72 #include "ffs/ffs_api.h"
73 #include "mfw_ffs.h"
74
75 #if (BOARD == 71)
76 #define ISAMPLE
77 #endif
78 //x0035544 29 Nov, 2005 MMI-SPR-55207
79 #ifndef NEPTUNE_BOARD //x0035544 Sudha - Guarded the below header file for Neptune.
80 #include "rv/rv_general.h"
81 #endif
82
83 #include "dspl.h"
84
85
86 /*Variable declarations*/
87
88 //Variable to track the different Camera states.
89 UBYTE camera_state = CAMERA_STATE_IDLE;
90
91 //Variable to store the quality factor.
92 static UBYTE quality_factor = QUALITY_STANDARD;
93
94 T_CAMA_VIEWFINDER_PARAMETERS viewfinder_parameters; //For Future Use, when viewfinder parameters can be configured.
95
96 //File name for the jpeg image to be saved in FFS.
97 extern char new_filename[CT_FILE_NAME_LENGTH];
98
99 //Flag to check whether viewfinder parameter configuration has changed.
100 UBYTE configure_flag = FALSE;
101
102 //Riviera Callback Functions for CAMIL API
103 static void mfw_cam_save_image_cb(void *parameter);
104 static void mfw_cam_get_viewfinder_param_cb(void *parameter);
105 static void mfw_cam_set_viewfinder_param_cb(void *parameter);
106 static void mfw_cam_set_viewfinder_mode_cb(void *parameter);
107 static void mfw_cam_enable_viewfinder_mode_cb(void *parameter);
108 static void mfw_cam_disable_viewfinder_mode_cb(void *parameter);
109
110 //Local function prototypes
111 void mfw_cam_set_viewfinder_param(T_CAMA_VIEWFINDER_PARAMETERS param);
112 void mfw_cam_set_viewfinder_param_color(UBYTE blackandwhite);
113 void mfw_cam_set_viewfinder_param_zoom(UBYTE zoom);
114
115 extern void display_saved_image(BOOL);
116
117 /*
118 ** Public function Definitions
119 */
120
121 /*******************************************************************************
122
123 $Function: mfw_cam_init
124
125 $Description: This function initialises the camil interface.
126
127 $Returns: None
128
129 $Arguments: None
130
131 *******************************************************************************/
132 void mfw_cam_init(void)
133 {
134 T_FFS_DIR dir;
135 T_FFS_RET ffsResult;
136 TRACE_EVENT("mfw_cam_init()");
137
138 ffsResult = ffs_opendir(JPEG_CONTENT_DIR,&dir);
139 if(EFFS_NOTFOUND == ffsResult)
140 {
141 //Directory does not exsists, create it and initialize the table and write it to FFS
142 ffsResult = ffs_mkdir(JPEG_CONTENT_DIR);
143 if(EFFS_OK == ffsResult)
144 {
145 TRACE_EVENT("Create Dir Passed");
146 }
147 else
148 TRACE_EVENT("Create Dir Failed");
149 }
150 // Initialize CAMIL interface.
151 if (camil_init() != RV_OK)
152 {
153 // @todo : use correct return code for error cases !
154 return ;
155 }
156
157 }
158
159 /*******************************************************************************
160
161 $Function: mfw_cam_get_viewfinder_param_cb
162
163 $Description: Callback to get the viewfinder parameters.
164
165 $Returns: None
166
167 $Arguments: Callback Parameter
168
169 *******************************************************************************/
170 static void mfw_cam_get_viewfinder_param_cb(void *parameter)
171 {
172 viewfinder_parameters = ((T_CAMA_MSG *)parameter)->body.viewfinder_parameters;
173 }
174
175 /*******************************************************************************
176
177 $Function: mfw_cam_exit
178
179 $Description: This function will tidy up any resources used by the Mfw Camera Module
180 on Power Down
181
182 $Returns: None
183
184 $Arguments: None
185
186 *******************************************************************************/
187 void mfw_cam_exit(void)
188 {
189
190 TRACE_EVENT("mfw_cam_exit()");
191
192 /* nothing to do here... RAM will be automatically cleaned, and the flash wasn't modified */
193 }
194
195 /*******************************************************************************
196
197 $Function: mfw_cam_enable_sensor_dummy_cb
198
199 $Description: dummy callback functions used to disable the camera
200
201 $Returns: None
202
203 $Arguments: Callback Parameter
204
205 *******************************************************************************/
206 static void mfw_cam_enable_sensor_dummy_cb(void *parameter)
207 {
208 TRACE_EVENT("mfw_cam_enable_sensor_dummy_cb()");
209 //Sept 15, 2005 REF: LOCOSTO-ENH-34257 - xpradipg
210 //replaced the flag with the function call, to migrate to the new Lcd APIs
211 dspl_control(DSPL_ACCESS_ENABLE);
212 }
213
214
215 /*******************************************************************************
216
217 $Function: mfw_cam_disable_sensor
218
219 $Description:Disables the camera - Called by the MMI
220
221 $Returns: Execution status
222
223 $Arguments: None
224 *******************************************************************************/
225 SHORT mfw_cam_disable_sensor(void)
226 {
227 TRACE_EVENT("mfw_cam_disable_sensor()");
228 camil_enable_camera(FALSE, mfw_cam_enable_sensor_dummy_cb);
229
230 return 1;
231 }
232
233
234 /*******************************************************************************
235
236 $Function: mfw_cam_enable_camera_cb
237
238 $Description: Callback for Enabling camera.
239
240 $Returns: None
241
242 $Arguments: Callback Parameter
243
244 *******************************************************************************/
245 static void mfw_cam_enable_camera_cb(void *parameter)
246 {
247
248 TRACE_EVENT("mfw_cam_enable_camera_cb()");
249 //Set the camera state to viewfinder.
250 camera_state = CAMERA_STATE_VIEWFINDER;
251 //Disable R2D refresh to stabilize lcd display of viewfinder
252 //Sept 15, 2005 REF: LOCOSTO-ENH-34257 - xpradipg
253 //replaced the flag with the function call, to migrate to the new Lcd APIs
254 dspl_control(DSPL_ACCESS_DISABLE);
255 //Set the viewfinder parameters
256 mfw_cam_set_viewfinder_param(viewfinder_parameters);
257 }
258
259
260 /*******************************************************************************
261
262 $Function: mfw_cam_launch_viewfinder_dma
263
264 $Description:launch camera in viewfinder mode
265
266 $Returns:Execution status
267
268 $Arguments: None
269
270 *******************************************************************************/
271 SHORT mfw_cam_launch_viewfinder_dma(void)
272 {
273 TRACE_EVENT("mfw_cam_launch_viewfinder_dma()");
274 camil_enable_camera (TRUE, mfw_cam_enable_camera_cb);
275 return 1;
276 }
277
278 /*******************************************************************************
279
280 $Function: mfw_cam_take_snapshot_cb
281
282 $Description: Callback for Camera take snapshot function.
283
284 $Returns: None
285
286 $Arguments: Callback Parameter
287
288 *******************************************************************************/
289 static void mfw_cam_take_snapshot_cb(void *parameter)
290 {
291
292 TRACE_EVENT("mfw_cam_take_snapshot_cb()");
293 //Set the camera state to Snapshot
294 camera_state = CAMERA_STATE_SNAPSHOT;
295 }
296
297 /*******************************************************************************
298
299 $Function: mfw_cam_take_snapshot
300
301 $Description:take a snapshot
302
303 $Returns:Execution status
304
305 $Arguments: None
306
307 *******************************************************************************/
308 SHORT mfw_cam_take_snapshot(void)
309 {
310 TRACE_EVENT("mfw_cam_take_snapshot()");
311 //Sept 15, 2005 REF: LOCOSTO-ENH-34257 - xpradipg
312 //replaced the flag with the function call, to migrate to the new Lcd APIs
313 dspl_control(DSPL_ACCESS_DISABLE);
314 camil_take_snapshot(mfw_cam_take_snapshot_cb);
315 return 1;
316 }
317
318 /*******************************************************************************
319
320 $Function: mfw_camera_test_save_snapshot_cb
321
322 $Description:save snapshot in phone memory
323
324 $Returns:Execution status
325
326 $Arguments: None
327
328 *******************************************************************************/
329 SHORT mfw_cam_save_snapshot(void)
330 {
331 //Sep 13, 2005 REF: SPR 33992 xdeepadh
332 //The fullpath will be included.
333 char filename[CT_FULL_PATH_LENGTH];
334
335 TRACE_EVENT("mfw_cam_save_snapshot()");
336 sprintf(filename,"%s/%s%d.jpg",JPEG_CONTENT_DIR, new_filename,(int)FFS_flashData.camera_file_counter);
337 TRACE_EVENT_P1("filename to be saved is %s",filename);
338 if(camil_save_image((UINT16)mfw_cam_get_quality_factor(),filename,mfw_cam_save_image_cb) == RV_OK)
339 {
340 TRACE_EVENT("mfw_cam_save_snapshot() passed");
341 FFS_flashData.camera_file_counter++;
342 flash_write();
343 return MFW_CAM_OK;
344 }
345 else
346 {
347 TRACE_EVENT("mfw_cam_save_snapshot() failed");
348 return MFW_CAM_FAILED;
349 }
350 }
351
352 /*******************************************************************************
353
354 $Function: mfw_cam_save_image_cb
355
356 $Description: Callback for save image
357
358 $Returns:None
359
360 $Arguments: Callback Parameter
361
362 *******************************************************************************/
363 static void mfw_cam_save_image_cb(void *parameter)
364 {
365 T_RV_RET status;
366 TRACE_EVENT("mfw_cam_save_image_cb()");
367 camera_state = CAMERA_STATE_VIEWFINDER;
368 //Sept 15, 2005 REF: LOCOSTO-ENH-34257 - xpradipgn
369 //replaced the flag with the function call, to migrate to the new Lcd APIs
370 dspl_control(DSPL_ACCESS_ENABLE);
371 if( ((T_CAMA_MSG*)parameter)->status != RV_OK)
372 {
373 TRACE_EVENT("ERROR SAVING IMAGE");
374 display_saved_image(FALSE);
375 }
376 else
377 {
378 TRACE_EVENT("IMAGE SAVED");
379 display_saved_image(TRUE);
380 }
381 }
382
383 /*******************************************************************************
384
385 $Function: mfw_cam_set_quality_factor
386
387 $Description: Set the quality factor .This will be used while saving the jpeg image in ffs.
388
389 $Returns: None
390
391 $Arguments: factor-quality factor to be used to save the image.
392
393 *******************************************************************************/
394 void mfw_cam_set_quality_factor(UBYTE factor)
395 {
396 TRACE_EVENT("mfw_cam_set_quality_factor()");
397 quality_factor = factor;
398 }
399
400 /*******************************************************************************
401
402 $Function: mfw_cam_get_quality_factor
403
404 $Description: This function returns the quality factor.
405
406 $Returns: The quality factor
407
408 $Arguments: None
409
410 *******************************************************************************/
411
412 UBYTE mfw_cam_get_quality_factor()
413 {
414 TRACE_EVENT("mfw_cam_get_quality_factor()");
415 return quality_factor;
416 }
417
418
419 /*******************************************************************************
420
421 $Function: mfw_cam_set_color
422
423 $Description:
424
425 $Returns:
426
427 $Arguments:
428
429 *******************************************************************************/
430 void mfw_cam_set_color(UBYTE factor)
431 {
432 TRACE_EVENT("mfw_cam_set_color()");
433 }
434 /*******************************************************************************
435
436 $Function: mfw_cam_set_viewfinder_param_cb
437
438 $Description: Callback for the Viewfinder set parameters.
439
440 $Returns:None
441
442 $Arguments: Callback Parameter
443
444 *******************************************************************************/
445 static void mfw_cam_set_viewfinder_param_cb(void *parameter)
446 {
447 TRACE_EVENT("mfw_cam_set_viewfinder_param_cb()");
448
449 configure_flag = FALSE;
450 /* start frame loop */
451 camil_set_viewfinder_mode(mfw_cam_set_viewfinder_mode_cb);
452 }
453
454 /*******************************************************************************
455
456 $Function: mfw_cam_set_viewfinder_param_color_cb
457
458 $Description: Callback for Viewfinder set Parameters
459
460 $Returns: None
461
462 $Arguments: Callback Parameter
463
464 *******************************************************************************/
465 static void mfw_cam_set_viewfinder_param_color_cb(void *parameter)
466 {
467 TRACE_EVENT("mfw_cam_set_viewfinder_param_color_cb()");
468 }
469
470 /*******************************************************************************
471
472 $Function: mfw_cam_set_viewfinder_param
473
474 $Description: This function sets the Viewfinder Parameters.
475 The camera will be started in the viewfinder mode.
476
477 $Returns: None
478
479 $Arguments: param- Viewfinder Parameters
480
481 *******************************************************************************/
482
483 void mfw_cam_set_viewfinder_param(T_CAMA_VIEWFINDER_PARAMETERS param)
484 {
485 TRACE_EVENT("mfw_cam_set_viewfinder_param()");
486 if(configure_flag)
487 {
488 camil_set_viewfinder_parameters(&param, mfw_cam_set_viewfinder_param_cb);
489 }
490 else
491 {
492 TRACE_EVENT("mfw_cam_set_viewfinder_param- no param chnaged.");
493 /* start frame loop */
494 camil_set_viewfinder_mode(mfw_cam_set_viewfinder_mode_cb);
495 }
496 }
497
498 /*******************************************************************************
499
500 $Function: mfw_cam_set_viewfinder_param_color
501
502 $Description: Sets the Viewfinder Parameter.
503
504 $Returns: None
505
506 $Arguments: blackandwhite- Viewfinder parameter
507
508 *******************************************************************************/
509
510 void mfw_cam_set_viewfinder_param_color(UBYTE blackandwhite)
511 {
512 TRACE_EVENT("mfw_cam_set_viewfinder_param_color()");
513 viewfinder_parameters.black_and_white = blackandwhite;
514 //Configurations have changed. Set the configure_flag to TRUE.
515 configure_flag = TRUE;
516 //Set the Viewfinder parameters .
517 //camil_set_viewfinder_parameters(&viewfinder_parameters, mfw_cam_set_viewfinder_param_color_cb);
518 }
519
520
521 /*******************************************************************************
522
523 $Function: mfw_cam_set_viewfinder_param_zoom
524
525 $Description: Sets the Viewfinder Parameter.
526
527 $Returns: None
528
529 $Arguments: zoom- Viewfinder parameter
530
531 *******************************************************************************/
532
533 void mfw_cam_set_viewfinder_param_zoom(UBYTE zoom)
534 {
535 TRACE_EVENT("mfw_cam_set_viewfinder_param_zoom()");
536 viewfinder_parameters.zoom = zoom;
537 //Configurations have chnaged. Set the configure_flag to TRUE.
538 configure_flag = TRUE;
539 //Set the Viewfinder parameters .
540 //camil_set_viewfinder_parameters(&viewfinder_parameters, mfw_cam_set_viewfinder_param_color_cb);
541 }
542
543
544
545 /*******************************************************************************
546
547 $Function: mfw_cam_set_viewfinder_mode_cb
548
549 $Description: Callback for Setting Viewfinder.
550
551 $Returns: None
552
553 $Arguments: Callback Parameter
554
555 *******************************************************************************/
556 static void mfw_cam_set_viewfinder_mode_cb(void *parameter)
557 {
558 TRACE_EVENT("mfw_cam_set_viewfinder_mode_cb()");
559 //added the refresh disable and state setting
560 //Sept 15, 2005 REF: LOCOSTO-ENH-34257 - xpradipg
561 //replaced the flag with the function call, to migrate to the new Lcd APIs
562 dspl_control(DSPL_ACCESS_DISABLE);
563 camera_state = CAMERA_STATE_VIEWFINDER;
564 }
565
566
567 /*******************************************************************************
568
569 $Function: mfw_cam_set_viewfinder_mode
570
571 $Description: This function disables and reenables camera and sets the viewfinder mode.
572
573 $Returns:None
574
575 $Arguments: None
576
577 *******************************************************************************/
578 #ifdef ISAMPLE
579 void mfw_cam_set_viewfinder_mode(void)
580 {
581 TRACE_EVENT("mfw_cam_set_viewfinder_mode()");
582 camera_state = CAMERA_STATE_VIEWFINDER;
583 camil_set_viewfinder_mode(mfw_cam_set_viewfinder_mode_cb);
584 }
585
586 #else //For ESAMPLE
587 void mfw_cam_set_viewfinder_mode(void)
588 {
589 TRACE_EVENT("mfw_cam_set_viewfinder_mode()");
590 camil_enable_camera(FALSE, mfw_cam_disable_viewfinder_mode_cb);
591 }
592 #endif
593
594 /*******************************************************************************
595
596 $Function: mfw_cam_enable_viewfinder_mode_cb
597
598 $Description: Callback for camil_enable_camera
599
600 $Returns:None
601
602 $Arguments: Callback Parameter
603
604 *******************************************************************************/
605 static void mfw_cam_enable_viewfinder_mode_cb(void *parameter)
606 {
607 TRACE_EVENT("mfw_cam_enable_viewfinder_mode_cb()");
608
609 //Disable R2D refresh (to be sure)
610 //Sept 15, 2005 REF: LOCOSTO-ENH-34257 - xpradipg
611 //replaced the flag with the function call, to migrate to the new Lcd APIs
612 dspl_control(DSPL_ACCESS_DISABLE);
613 camil_set_viewfinder_mode(mfw_cam_set_viewfinder_mode_cb);
614 }
615
616 /*******************************************************************************
617
618 $Function: mfw_cam_disable_viewfinder_mode_cb
619
620 $Description: Callback for disabling camera
621
622 $Returns:None
623
624 $Arguments: Callback Parameter
625
626 *******************************************************************************/
627 static void mfw_cam_disable_viewfinder_mode_cb(void *parameter)
628 {
629 TRACE_EVENT("mfw_cam_disable_viewfinder_mode_cb()");
630 camil_enable_camera(TRUE, mfw_cam_enable_viewfinder_mode_cb);
631 }
632
633
634
635