forked from MTCM9/libcamera2
-
Notifications
You must be signed in to change notification settings - Fork 1
/
QualcommCameraHardware.cpp
7354 lines (6535 loc) · 267 KB
/
QualcommCameraHardware.cpp
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
** Copyright 2008, Google Inc.
** Copyright (c) 2009-2010 Code Aurora Forum. All rights reserved.
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
#define LOG_NDEBUG 0
#define LOG_NIDEBUG 0
#define LOG_TAG "QualcommCameraHardware"
#include <utils/Log.h>
#include "QualcommCameraHardware.h"
#include <utils/Errors.h>
#include <utils/threads.h>
#include <binder/MemoryHeapPmem.h>
#include <utils/String16.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <cutils/properties.h>
#include <math.h>
#if HAVE_ANDROID_OS
#include <linux/android_pmem.h>
#endif
#include <linux/ioctl.h>
#include <camera/CameraParameters.h>
#include <media/mediarecorder.h>
#include <system/camera.h>
#include "linux/msm_mdp.h"
#include <linux/fb.h>
#define LIKELY(exp) __builtin_expect(!!(exp), 1)
#define UNLIKELY(exp) __builtin_expect(!!(exp), 0)
#define CAMERA_HAL_UNUSED(expr) do { (void)(expr); } while (0)
extern "C" {
#include <fcntl.h>
#include <time.h>
#include <pthread.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <termios.h>
#include <assert.h>
#include <stdlib.h>
#include <ctype.h>
#include <signal.h>
#include <errno.h>
#include <sys/mman.h>
#include <sys/system_properties.h>
#include <sys/time.h>
#include <stdlib.h>
#if 0
#include <camera.h>
#include <cam_fifo.h>
#include <liveshot.h>
#include <jpege.h>
#include <jpeg_encoder.h>
#endif
#define LIVESHOT_SUCCESS 0
#define DUMP_LIVESHOT_JPEG_FILE 0
#define DEFAULT_PICTURE_WIDTH 640
#define DEFAULT_PICTURE_HEIGHT 480
#define THUMBNAIL_BUFFER_SIZE (THUMBNAIL_WIDTH * THUMBNAIL_HEIGHT * 3/2)
#define MAX_ZOOM_LEVEL 5
#define NOT_FOUND -1
// Number of video buffers held by kernal (initially 1,2 &3)
#define ACTIVE_VIDEO_BUFFERS 3
#define APP_ORIENTATION 0
#if DLOPEN_LIBMMCAMERA
#include <dlfcn.h>
void* (*LINK_cam_conf)(void *data);
void* (*LINK_cam_frame)(void *data);
bool (*LINK_jpeg_encoder_init)();
void (*LINK_jpeg_encoder_join)();
bool (*LINK_jpeg_encoder_encode)(const cam_ctrl_dimension_t *dimen,
const uint8_t *thumbnailbuf, int thumbnailfd,
const uint8_t *snapshotbuf, int snapshotfd,
common_crop_t *scaling_parms, exif_tags_info_t *exif_data,
int exif_table_numEntries);
void (*LINK_camframe_terminate)(void);
//for 720p
// Function to add a video buffer to free Q
void (*LINK_camframe_free_video)(struct msm_frame *frame);
// Function pointer , called by camframe when a video frame is available.
void (**LINK_camframe_video_callback)(struct msm_frame * frame);
// To flush free Q in cam frame.
void (*LINK_cam_frame_flush_free_video)(void);
int8_t (*LINK_jpeg_encoder_setMainImageQuality)(uint32_t quality);
int8_t (*LINK_jpeg_encoder_setThumbnailQuality)(uint32_t quality);
int8_t (*LINK_jpeg_encoder_setRotation)(uint32_t rotation);
int8_t (*LINK_jpeg_encoder_get_buffer_offset)(uint32_t width, uint32_t height,
uint32_t* p_y_offset,
uint32_t* p_cbcr_offset,
uint32_t* p_buf_size);
int8_t (*LINK_jpeg_encoder_setLocation)(const camera_position_type *location);
const struct camera_size_type *(*LINK_default_sensor_get_snapshot_sizes)(int *len);
int (*LINK_launch_cam_conf_thread)(void);
int (*LINK_release_cam_conf_thread)(void);
mm_camera_status_t (*LINK_mm_camera_config_init)(mm_camera_config *);
mm_camera_status_t (*LINK_mm_camera_config_deinit)(mm_camera_config *);
int8_t (*LINK_zoom_crop_upscale)(uint32_t width, uint32_t height,
uint32_t cropped_width, uint32_t cropped_height, uint8_t *img_buf);
// callbacks
void (**LINK_mmcamera_camframe_callback)(struct msm_frame *frame);
void (**LINK_mmcamera_camstats_callback)(camstats_type stype, camera_preview_histogram_info* histinfo);
void (**LINK_mmcamera_jpegfragment_callback)(uint8_t *buff_ptr,
uint32_t buff_size);
void (**LINK_mmcamera_jpeg_callback)(jpeg_event_t status);
void (**LINK_mmcamera_shutter_callback)(common_crop_t *crop);
void (**LINK_camframe_error_callback)(camera_error_type err);
void (**LINK_mmcamera_liveshot_callback)(liveshot_status status, uint32_t jpeg_size);
void (**LINK_cancel_liveshot)(void);
int8_t (*LINK_set_liveshot_params)(uint32_t a_width, uint32_t a_height, exif_tags_info_t *a_exif_data,
int a_exif_numEntries, uint8_t* a_out_buffer, uint32_t a_outbuffer_size);
#else
#define LINK_cam_conf cam_conf
#define LINK_cam_frame cam_frame
#define LINK_jpeg_encoder_init jpeg_encoder_init
#define LINK_jpeg_encoder_join jpeg_encoder_join
#define LINK_jpeg_encoder_encode jpeg_encoder_encode
#define LINK_camframe_terminate camframe_terminate
#define LINK_jpeg_encoder_setMainImageQuality jpeg_encoder_setMainImageQuality
#define LINK_jpeg_encoder_setThumbnailQuality jpeg_encoder_setThumbnailQuality
#define LINK_jpeg_encoder_setRotation jpeg_encoder_setRotation
#define LINK_jpeg_encoder_get_buffer_offset jpeg_encoder_get_buffer_offset
#define LINK_jpeg_encoder_setLocation jpeg_encoder_setLocation
#define LINK_default_sensor_get_snapshot_sizes default_sensor_get_snapshot_sizes
#define LINK_launch_cam_conf_thread launch_cam_conf_thread
#define LINK_release_cam_conf_thread release_cam_conf_thread
#define LINK_zoom_crop_upscale zoom_crop_upscale
#define LINK_mm_camera_config_init mm_camera_config_init
#define LINK_mm_camera_config_deinit mm_camera_config_deinit
extern void (*mmcamera_camframe_callback)(struct msm_frame *frame);
extern void (*mmcamera_camstats_callback)(camstats_type stype, camera_preview_histogram_info* histinfo);
extern void (*mmcamera_jpegfragment_callback)(uint8_t *buff_ptr,
uint32_t buff_size);
extern void (*mmcamera_jpeg_callback)(jpeg_event_t status);
extern void (*mmcamera_shutter_callback)(common_crop_t *crop);
extern void (*mmcamera_liveshot_callback)(liveshot_status status, uint32_t jpeg_size);
#define LINK_set_liveshot_params set_liveshot_params
#endif
} // extern "C"
#ifndef HAVE_CAMERA_SIZE_TYPE
struct camera_size_type {
int width;
int height;
};
#endif
typedef struct crop_info_struct {
int32_t x;
int32_t y;
int32_t w;
int32_t h;
} zoom_crop_info;
union zoomimage
{
char d[sizeof(struct mdp_blit_req_list) + sizeof(struct mdp_blit_req) * 1];
struct mdp_blit_req_list list;
} zoomImage;
//Default to QVGA
#define DEFAULT_PREVIEW_WIDTH 320
#define DEFAULT_PREVIEW_HEIGHT 240
//Default FPS
#define MINIMUM_FPS 15
#define MAXIMUM_FPS 31
#define DEFAULT_FPS MAXIMUM_FPS
/*
* Modifying preview size requires modification
* in bitmasks for boardproperties
*/
static const camera_size_type preview_sizes[] = {
{ 1920, 1088 }, //1080p
{ 1280, 720 }, // 720P, reserved
{ 960, 720 },
{ 800, 480 }, // WVGA
{ 768, 432 },
{ 720, 480 },
{ 640, 480 }, // VGA
{ 576, 432 },
{ 480, 320 }, // HVGA
{ 384, 288 },
{ 352, 288 }, // CIF
{ 320, 240 }, // QVGA
{ 240, 160 }, // SQVGA
{ 176, 144 }, // QCIF
};
#define PREVIEW_SIZE_COUNT (sizeof(preview_sizes)/sizeof(camera_size_type))
static camera_size_type supportedPreviewSizes[PREVIEW_SIZE_COUNT];
static unsigned int previewSizeCount;
board_property boardProperties[] = {
{TARGET_MSM7625, 0x00000fff, false, false, false},
{TARGET_MSM7627, 0x000006ff, false, false, false},
{TARGET_MSM7630, 0x00000fff, true, true, false},
{TARGET_MSM8660, 0x00002fff, true, true, false},
{TARGET_QSD8250, 0x00000fff, false, false, false}
};
/* TODO
* Ideally this should be a populated by lower layers.
* But currently this is no API to do that at lower layer.
* Hence populating with default sizes for now. This needs
* to be changed once the API is supported.
*/
//sorted on column basis
static const camera_size_type picture_sizes[] = {
{ 4000, 3000 }, // 12MP
{ 3200, 2400 }, // 8MP
{ 2592, 1944 }, // 5MP
{ 2048, 1536 }, // 3MP QXGA
{ 1920, 1080 }, //HD1080
{ 1600, 1200 }, // 2MP UXGA
{ 1280, 1024 }, //SXGA
{ 1280, 768 }, //WXGA
{ 1280, 720 }, //HD720
{ 1024, 768}, // 1MP XGA
{ 800, 600 }, //SVGA
{ 800, 480 }, // WVGA
{ 640, 480 }, // VGA
{ 352, 288 }, //CIF
{ 320, 240 }, // QVGA
{ 176, 144 } // QCIF
};
static int PICTURE_SIZE_COUNT = sizeof(picture_sizes)/sizeof(camera_size_type);
static const camera_size_type * picture_sizes_ptr;
static int supportedPictureSizesCount;
static liveshotState liveshot_state = LIVESHOT_DONE;
#ifdef Q12
#undef Q12
#endif
#define Q12 4096
static const target_map targetList [] = {
{ "msm7625", TARGET_MSM7625 },
{ "msm7627", TARGET_MSM7627 },
{ "qsd8250", TARGET_QSD8250 },
{ "msm7x30", TARGET_MSM7630 },
{ "msm8660", TARGET_MSM8660 }
};
static targetType mCurrentTarget = TARGET_MAX;
typedef struct {
uint32_t aspect_ratio;
uint32_t width;
uint32_t height;
} thumbnail_size_type;
static thumbnail_size_type thumbnail_sizes[] = {
{ 7281, 512, 288 }, //1.777778
{ 6826, 480, 288 }, //1.666667
{ 6808, 256, 154 }, //1.662337
{ 6144, 432, 288 }, //1.5
{ 5461, 512, 384 }, //1.333333
{ 5006, 352, 288 }, //1.222222
};
#define THUMBNAIL_SIZE_COUNT (sizeof(thumbnail_sizes)/sizeof(thumbnail_size_type))
#define DEFAULT_THUMBNAIL_SETTING 4
#define THUMBNAIL_WIDTH_STR "512"
#define THUMBNAIL_HEIGHT_STR "288"
#define THUMBNAIL_SMALL_HEIGHT 144
static camera_size_type jpeg_thumbnail_sizes[] = {
{ 512, 288 },
{ 480, 288 },
{ 256, 154 },
{ 432, 288 },
{ 192, 144 },
{ 352, 288 },
{0,0}
};
//supported preview fps ranges should be added to this array in the form (minFps,maxFps)
static android::FPSRange FpsRangesSupported[1] = {android::FPSRange(MINIMUM_FPS*1000,MAXIMUM_FPS*1000)};
#define FPS_RANGES_SUPPORTED_COUNT (sizeof(FpsRangesSupported)/sizeof(FpsRangesSupported[0]))
#define JPEG_THUMBNAIL_SIZE_COUNT (sizeof(jpeg_thumbnail_sizes)/sizeof(camera_size_type))
static int attr_lookup(const str_map arr[], int len, const char *name)
{
if (name) {
for (int i = 0; i < len; i++) {
if (!strcmp(arr[i].desc, name))
return arr[i].val;
}
}
return NOT_FOUND;
}
// round to the next power of two
static inline unsigned clp2(unsigned x)
{
x = x - 1;
x = x | (x >> 1);
x = x | (x >> 2);
x = x | (x >> 4);
x = x | (x >> 8);
x = x | (x >>16);
return x + 1;
}
static int exif_table_numEntries = 0;
#define MAX_EXIF_TABLE_ENTRIES 11
exif_tags_info_t exif_data[MAX_EXIF_TABLE_ENTRIES];
static zoom_crop_info zoomCropInfo;
static void *mLastQueuedFrame = NULL;
#define RECORD_BUFFERS 9
#define RECORD_BUFFERS_8x50 8
static int kRecordBufferCount;
/* controls whether VPE is avialable for the target
* under consideration.
* 1: VPE support is available
* 0: VPE support is not available (default)
*/
static bool mVpeEnabled;
static int HAL_numOfCameras = 0;
static camera_info_t HAL_cameraInfo[MSM_MAX_CAMERA_SENSORS];
static int HAL_currentCameraId = 0;
namespace android {
static const int PICTURE_FORMAT_JPEG = 1;
static const int PICTURE_FORMAT_RAW = 2;
// from aeecamera.h
static const str_map whitebalance[] = {
{ CameraParameters::WHITE_BALANCE_AUTO, CAMERA_WB_AUTO },
{ CameraParameters::WHITE_BALANCE_INCANDESCENT, CAMERA_WB_INCANDESCENT },
{ CameraParameters::WHITE_BALANCE_FLUORESCENT, CAMERA_WB_FLUORESCENT },
{ CameraParameters::WHITE_BALANCE_DAYLIGHT, CAMERA_WB_DAYLIGHT },
{ CameraParameters::WHITE_BALANCE_CLOUDY_DAYLIGHT, CAMERA_WB_CLOUDY_DAYLIGHT }
};
// from camera_effect_t. This list must match aeecamera.h
static const str_map effects[] = {
{ CameraParameters::EFFECT_NONE, CAMERA_EFFECT_OFF },
{ CameraParameters::EFFECT_MONO, CAMERA_EFFECT_MONO },
{ CameraParameters::EFFECT_NEGATIVE, CAMERA_EFFECT_NEGATIVE },
{ CameraParameters::EFFECT_SOLARIZE, CAMERA_EFFECT_SOLARIZE },
{ CameraParameters::EFFECT_SEPIA, CAMERA_EFFECT_SEPIA },
{ CameraParameters::EFFECT_POSTERIZE, CAMERA_EFFECT_POSTERIZE },
{ CameraParameters::EFFECT_WHITEBOARD, CAMERA_EFFECT_WHITEBOARD },
{ CameraParameters::EFFECT_BLACKBOARD, CAMERA_EFFECT_BLACKBOARD },
{ CameraParameters::EFFECT_AQUA, CAMERA_EFFECT_AQUA }
};
// from qcamera/common/camera.h
static const str_map autoexposure[] = {
{ CameraParameters::AUTO_EXPOSURE_FRAME_AVG, CAMERA_AEC_FRAME_AVERAGE },
{ CameraParameters::AUTO_EXPOSURE_CENTER_WEIGHTED, CAMERA_AEC_CENTER_WEIGHTED },
{ CameraParameters::AUTO_EXPOSURE_SPOT_METERING, CAMERA_AEC_SPOT_METERING }
};
// from qcamera/common/camera.h
static const str_map antibanding[] = {
{ CameraParameters::ANTIBANDING_OFF, CAMERA_ANTIBANDING_OFF },
{ CameraParameters::ANTIBANDING_50HZ, CAMERA_ANTIBANDING_50HZ },
{ CameraParameters::ANTIBANDING_60HZ, CAMERA_ANTIBANDING_60HZ },
{ CameraParameters::ANTIBANDING_AUTO, CAMERA_ANTIBANDING_AUTO }
};
/* Mapping from MCC to antibanding type */
struct country_map {
uint32_t country_code;
camera_antibanding_type type;
};
static struct country_map country_numeric[] = {
{ 202, CAMERA_ANTIBANDING_50HZ }, // Greece
{ 204, CAMERA_ANTIBANDING_50HZ }, // Netherlands
{ 206, CAMERA_ANTIBANDING_50HZ }, // Belgium
{ 208, CAMERA_ANTIBANDING_50HZ }, // France
{ 212, CAMERA_ANTIBANDING_50HZ }, // Monaco
{ 213, CAMERA_ANTIBANDING_50HZ }, // Andorra
{ 214, CAMERA_ANTIBANDING_50HZ }, // Spain
{ 216, CAMERA_ANTIBANDING_50HZ }, // Hungary
{ 219, CAMERA_ANTIBANDING_50HZ }, // Croatia
{ 220, CAMERA_ANTIBANDING_50HZ }, // Serbia
{ 222, CAMERA_ANTIBANDING_50HZ }, // Italy
{ 226, CAMERA_ANTIBANDING_50HZ }, // Romania
{ 228, CAMERA_ANTIBANDING_50HZ }, // Switzerland
{ 230, CAMERA_ANTIBANDING_50HZ }, // Czech Republic
{ 231, CAMERA_ANTIBANDING_50HZ }, // Slovakia
{ 232, CAMERA_ANTIBANDING_50HZ }, // Austria
{ 234, CAMERA_ANTIBANDING_50HZ }, // United Kingdom
{ 235, CAMERA_ANTIBANDING_50HZ }, // United Kingdom
{ 238, CAMERA_ANTIBANDING_50HZ }, // Denmark
{ 240, CAMERA_ANTIBANDING_50HZ }, // Sweden
{ 242, CAMERA_ANTIBANDING_50HZ }, // Norway
{ 244, CAMERA_ANTIBANDING_50HZ }, // Finland
{ 246, CAMERA_ANTIBANDING_50HZ }, // Lithuania
{ 247, CAMERA_ANTIBANDING_50HZ }, // Latvia
{ 248, CAMERA_ANTIBANDING_50HZ }, // Estonia
{ 250, CAMERA_ANTIBANDING_50HZ }, // Russian Federation
{ 255, CAMERA_ANTIBANDING_50HZ }, // Ukraine
{ 257, CAMERA_ANTIBANDING_50HZ }, // Belarus
{ 259, CAMERA_ANTIBANDING_50HZ }, // Moldova
{ 260, CAMERA_ANTIBANDING_50HZ }, // Poland
{ 262, CAMERA_ANTIBANDING_50HZ }, // Germany
{ 266, CAMERA_ANTIBANDING_50HZ }, // Gibraltar
{ 268, CAMERA_ANTIBANDING_50HZ }, // Portugal
{ 270, CAMERA_ANTIBANDING_50HZ }, // Luxembourg
{ 272, CAMERA_ANTIBANDING_50HZ }, // Ireland
{ 274, CAMERA_ANTIBANDING_50HZ }, // Iceland
{ 276, CAMERA_ANTIBANDING_50HZ }, // Albania
{ 278, CAMERA_ANTIBANDING_50HZ }, // Malta
{ 280, CAMERA_ANTIBANDING_50HZ }, // Cyprus
{ 282, CAMERA_ANTIBANDING_50HZ }, // Georgia
{ 283, CAMERA_ANTIBANDING_50HZ }, // Armenia
{ 284, CAMERA_ANTIBANDING_50HZ }, // Bulgaria
{ 286, CAMERA_ANTIBANDING_50HZ }, // Turkey
{ 288, CAMERA_ANTIBANDING_50HZ }, // Faroe Islands
{ 290, CAMERA_ANTIBANDING_50HZ }, // Greenland
{ 293, CAMERA_ANTIBANDING_50HZ }, // Slovenia
{ 294, CAMERA_ANTIBANDING_50HZ }, // Macedonia
{ 295, CAMERA_ANTIBANDING_50HZ }, // Liechtenstein
{ 297, CAMERA_ANTIBANDING_50HZ }, // Montenegro
{ 302, CAMERA_ANTIBANDING_60HZ }, // Canada
{ 310, CAMERA_ANTIBANDING_60HZ }, // United States of America
{ 311, CAMERA_ANTIBANDING_60HZ }, // United States of America
{ 312, CAMERA_ANTIBANDING_60HZ }, // United States of America
{ 313, CAMERA_ANTIBANDING_60HZ }, // United States of America
{ 314, CAMERA_ANTIBANDING_60HZ }, // United States of America
{ 315, CAMERA_ANTIBANDING_60HZ }, // United States of America
{ 316, CAMERA_ANTIBANDING_60HZ }, // United States of America
{ 330, CAMERA_ANTIBANDING_60HZ }, // Puerto Rico
{ 334, CAMERA_ANTIBANDING_60HZ }, // Mexico
{ 338, CAMERA_ANTIBANDING_50HZ }, // Jamaica
{ 340, CAMERA_ANTIBANDING_50HZ }, // Martinique
{ 342, CAMERA_ANTIBANDING_50HZ }, // Barbados
{ 346, CAMERA_ANTIBANDING_60HZ }, // Cayman Islands
{ 350, CAMERA_ANTIBANDING_60HZ }, // Bermuda
{ 352, CAMERA_ANTIBANDING_50HZ }, // Grenada
{ 354, CAMERA_ANTIBANDING_60HZ }, // Montserrat
{ 362, CAMERA_ANTIBANDING_50HZ }, // Netherlands Antilles
{ 363, CAMERA_ANTIBANDING_60HZ }, // Aruba
{ 364, CAMERA_ANTIBANDING_60HZ }, // Bahamas
{ 365, CAMERA_ANTIBANDING_60HZ }, // Anguilla
{ 366, CAMERA_ANTIBANDING_50HZ }, // Dominica
{ 368, CAMERA_ANTIBANDING_60HZ }, // Cuba
{ 370, CAMERA_ANTIBANDING_60HZ }, // Dominican Republic
{ 372, CAMERA_ANTIBANDING_60HZ }, // Haiti
{ 401, CAMERA_ANTIBANDING_50HZ }, // Kazakhstan
{ 402, CAMERA_ANTIBANDING_50HZ }, // Bhutan
{ 404, CAMERA_ANTIBANDING_50HZ }, // India
{ 405, CAMERA_ANTIBANDING_50HZ }, // India
{ 410, CAMERA_ANTIBANDING_50HZ }, // Pakistan
{ 413, CAMERA_ANTIBANDING_50HZ }, // Sri Lanka
{ 414, CAMERA_ANTIBANDING_50HZ }, // Myanmar
{ 415, CAMERA_ANTIBANDING_50HZ }, // Lebanon
{ 416, CAMERA_ANTIBANDING_50HZ }, // Jordan
{ 417, CAMERA_ANTIBANDING_50HZ }, // Syria
{ 418, CAMERA_ANTIBANDING_50HZ }, // Iraq
{ 419, CAMERA_ANTIBANDING_50HZ }, // Kuwait
{ 420, CAMERA_ANTIBANDING_60HZ }, // Saudi Arabia
{ 421, CAMERA_ANTIBANDING_50HZ }, // Yemen
{ 422, CAMERA_ANTIBANDING_50HZ }, // Oman
{ 424, CAMERA_ANTIBANDING_50HZ }, // United Arab Emirates
{ 425, CAMERA_ANTIBANDING_50HZ }, // Israel
{ 426, CAMERA_ANTIBANDING_50HZ }, // Bahrain
{ 427, CAMERA_ANTIBANDING_50HZ }, // Qatar
{ 428, CAMERA_ANTIBANDING_50HZ }, // Mongolia
{ 429, CAMERA_ANTIBANDING_50HZ }, // Nepal
{ 430, CAMERA_ANTIBANDING_50HZ }, // United Arab Emirates
{ 431, CAMERA_ANTIBANDING_50HZ }, // United Arab Emirates
{ 432, CAMERA_ANTIBANDING_50HZ }, // Iran
{ 434, CAMERA_ANTIBANDING_50HZ }, // Uzbekistan
{ 436, CAMERA_ANTIBANDING_50HZ }, // Tajikistan
{ 437, CAMERA_ANTIBANDING_50HZ }, // Kyrgyz Rep
{ 438, CAMERA_ANTIBANDING_50HZ }, // Turkmenistan
{ 440, CAMERA_ANTIBANDING_60HZ }, // Japan
{ 441, CAMERA_ANTIBANDING_60HZ }, // Japan
{ 452, CAMERA_ANTIBANDING_50HZ }, // Vietnam
{ 454, CAMERA_ANTIBANDING_50HZ }, // Hong Kong
{ 455, CAMERA_ANTIBANDING_50HZ }, // Macao
{ 456, CAMERA_ANTIBANDING_50HZ }, // Cambodia
{ 457, CAMERA_ANTIBANDING_50HZ }, // Laos
{ 460, CAMERA_ANTIBANDING_50HZ }, // China
{ 466, CAMERA_ANTIBANDING_60HZ }, // Taiwan
{ 470, CAMERA_ANTIBANDING_50HZ }, // Bangladesh
{ 472, CAMERA_ANTIBANDING_50HZ }, // Maldives
{ 502, CAMERA_ANTIBANDING_50HZ }, // Malaysia
{ 505, CAMERA_ANTIBANDING_50HZ }, // Australia
{ 510, CAMERA_ANTIBANDING_50HZ }, // Indonesia
{ 514, CAMERA_ANTIBANDING_50HZ }, // East Timor
{ 515, CAMERA_ANTIBANDING_60HZ }, // Philippines
{ 520, CAMERA_ANTIBANDING_50HZ }, // Thailand
{ 525, CAMERA_ANTIBANDING_50HZ }, // Singapore
{ 530, CAMERA_ANTIBANDING_50HZ }, // New Zealand
{ 535, CAMERA_ANTIBANDING_60HZ }, // Guam
{ 536, CAMERA_ANTIBANDING_50HZ }, // Nauru
{ 537, CAMERA_ANTIBANDING_50HZ }, // Papua New Guinea
{ 539, CAMERA_ANTIBANDING_50HZ }, // Tonga
{ 541, CAMERA_ANTIBANDING_50HZ }, // Vanuatu
{ 542, CAMERA_ANTIBANDING_50HZ }, // Fiji
{ 544, CAMERA_ANTIBANDING_60HZ }, // American Samoa
{ 545, CAMERA_ANTIBANDING_50HZ }, // Kiribati
{ 546, CAMERA_ANTIBANDING_50HZ }, // New Caledonia
{ 548, CAMERA_ANTIBANDING_50HZ }, // Cook Islands
{ 602, CAMERA_ANTIBANDING_50HZ }, // Egypt
{ 603, CAMERA_ANTIBANDING_50HZ }, // Algeria
{ 604, CAMERA_ANTIBANDING_50HZ }, // Morocco
{ 605, CAMERA_ANTIBANDING_50HZ }, // Tunisia
{ 606, CAMERA_ANTIBANDING_50HZ }, // Libya
{ 607, CAMERA_ANTIBANDING_50HZ }, // Gambia
{ 608, CAMERA_ANTIBANDING_50HZ }, // Senegal
{ 609, CAMERA_ANTIBANDING_50HZ }, // Mauritania
{ 610, CAMERA_ANTIBANDING_50HZ }, // Mali
{ 611, CAMERA_ANTIBANDING_50HZ }, // Guinea
{ 613, CAMERA_ANTIBANDING_50HZ }, // Burkina Faso
{ 614, CAMERA_ANTIBANDING_50HZ }, // Niger
{ 616, CAMERA_ANTIBANDING_50HZ }, // Benin
{ 617, CAMERA_ANTIBANDING_50HZ }, // Mauritius
{ 618, CAMERA_ANTIBANDING_50HZ }, // Liberia
{ 619, CAMERA_ANTIBANDING_50HZ }, // Sierra Leone
{ 620, CAMERA_ANTIBANDING_50HZ }, // Ghana
{ 621, CAMERA_ANTIBANDING_50HZ }, // Nigeria
{ 622, CAMERA_ANTIBANDING_50HZ }, // Chad
{ 623, CAMERA_ANTIBANDING_50HZ }, // Central African Republic
{ 624, CAMERA_ANTIBANDING_50HZ }, // Cameroon
{ 625, CAMERA_ANTIBANDING_50HZ }, // Cape Verde
{ 627, CAMERA_ANTIBANDING_50HZ }, // Equatorial Guinea
{ 631, CAMERA_ANTIBANDING_50HZ }, // Angola
{ 633, CAMERA_ANTIBANDING_50HZ }, // Seychelles
{ 634, CAMERA_ANTIBANDING_50HZ }, // Sudan
{ 636, CAMERA_ANTIBANDING_50HZ }, // Ethiopia
{ 637, CAMERA_ANTIBANDING_50HZ }, // Somalia
{ 638, CAMERA_ANTIBANDING_50HZ }, // Djibouti
{ 639, CAMERA_ANTIBANDING_50HZ }, // Kenya
{ 640, CAMERA_ANTIBANDING_50HZ }, // Tanzania
{ 641, CAMERA_ANTIBANDING_50HZ }, // Uganda
{ 642, CAMERA_ANTIBANDING_50HZ }, // Burundi
{ 643, CAMERA_ANTIBANDING_50HZ }, // Mozambique
{ 645, CAMERA_ANTIBANDING_50HZ }, // Zambia
{ 646, CAMERA_ANTIBANDING_50HZ }, // Madagascar
{ 647, CAMERA_ANTIBANDING_50HZ }, // France
{ 648, CAMERA_ANTIBANDING_50HZ }, // Zimbabwe
{ 649, CAMERA_ANTIBANDING_50HZ }, // Namibia
{ 650, CAMERA_ANTIBANDING_50HZ }, // Malawi
{ 651, CAMERA_ANTIBANDING_50HZ }, // Lesotho
{ 652, CAMERA_ANTIBANDING_50HZ }, // Botswana
{ 653, CAMERA_ANTIBANDING_50HZ }, // Swaziland
{ 654, CAMERA_ANTIBANDING_50HZ }, // Comoros
{ 655, CAMERA_ANTIBANDING_50HZ }, // South Africa
{ 657, CAMERA_ANTIBANDING_50HZ }, // Eritrea
{ 702, CAMERA_ANTIBANDING_60HZ }, // Belize
{ 704, CAMERA_ANTIBANDING_60HZ }, // Guatemala
{ 706, CAMERA_ANTIBANDING_60HZ }, // El Salvador
{ 708, CAMERA_ANTIBANDING_60HZ }, // Honduras
{ 710, CAMERA_ANTIBANDING_60HZ }, // Nicaragua
{ 712, CAMERA_ANTIBANDING_60HZ }, // Costa Rica
{ 714, CAMERA_ANTIBANDING_60HZ }, // Panama
{ 722, CAMERA_ANTIBANDING_50HZ }, // Argentina
{ 724, CAMERA_ANTIBANDING_60HZ }, // Brazil
{ 730, CAMERA_ANTIBANDING_50HZ }, // Chile
{ 732, CAMERA_ANTIBANDING_60HZ }, // Colombia
{ 734, CAMERA_ANTIBANDING_60HZ }, // Venezuela
{ 736, CAMERA_ANTIBANDING_50HZ }, // Bolivia
{ 738, CAMERA_ANTIBANDING_60HZ }, // Guyana
{ 740, CAMERA_ANTIBANDING_60HZ }, // Ecuador
{ 742, CAMERA_ANTIBANDING_50HZ }, // French Guiana
{ 744, CAMERA_ANTIBANDING_50HZ }, // Paraguay
{ 746, CAMERA_ANTIBANDING_60HZ }, // Suriname
{ 748, CAMERA_ANTIBANDING_50HZ }, // Uruguay
{ 750, CAMERA_ANTIBANDING_50HZ }, // Falkland Islands
};
static const str_map scenemode[] = {
{ CameraParameters::SCENE_MODE_AUTO, CAMERA_BESTSHOT_OFF },
{ CameraParameters::SCENE_MODE_ACTION, CAMERA_BESTSHOT_ACTION },
{ CameraParameters::SCENE_MODE_PORTRAIT, CAMERA_BESTSHOT_PORTRAIT },
{ CameraParameters::SCENE_MODE_LANDSCAPE, CAMERA_BESTSHOT_LANDSCAPE },
{ CameraParameters::SCENE_MODE_NIGHT, CAMERA_BESTSHOT_NIGHT },
{ CameraParameters::SCENE_MODE_NIGHT_PORTRAIT, CAMERA_BESTSHOT_NIGHT_PORTRAIT },
{ CameraParameters::SCENE_MODE_THEATRE, CAMERA_BESTSHOT_THEATRE },
{ CameraParameters::SCENE_MODE_BEACH, CAMERA_BESTSHOT_BEACH },
{ CameraParameters::SCENE_MODE_SNOW, CAMERA_BESTSHOT_SNOW },
{ CameraParameters::SCENE_MODE_SUNSET, CAMERA_BESTSHOT_SUNSET },
{ CameraParameters::SCENE_MODE_STEADYPHOTO, CAMERA_BESTSHOT_ANTISHAKE },
{ CameraParameters::SCENE_MODE_FIREWORKS , CAMERA_BESTSHOT_FIREWORKS },
{ CameraParameters::SCENE_MODE_SPORTS , CAMERA_BESTSHOT_SPORTS },
{ CameraParameters::SCENE_MODE_PARTY, CAMERA_BESTSHOT_PARTY },
{ CameraParameters::SCENE_MODE_CANDLELIGHT, CAMERA_BESTSHOT_CANDLELIGHT },
{ CameraParameters::SCENE_MODE_BACKLIGHT, CAMERA_BESTSHOT_BACKLIGHT },
{ CameraParameters::SCENE_MODE_FLOWERS, CAMERA_BESTSHOT_FLOWERS },
{ CameraParameters::SCENE_MODE_AR, CAMERA_BESTSHOT_AR },
};
static const str_map scenedetect[] = {
{ CameraParameters::SCENE_DETECT_OFF, FALSE },
{ CameraParameters::SCENE_DETECT_ON, TRUE },
};
#define country_number (sizeof(country_numeric) / sizeof(country_map))
/* TODO : setting dummy values as of now, need to query for correct
* values from sensor in future
*/
#define CAMERA_FOCAL_LENGTH_DEFAULT 4.31
#define CAMERA_HORIZONTAL_VIEW_ANGLE_DEFAULT 54.8
#define CAMERA_VERTICAL_VIEW_ANGLE_DEFAULT 42.5
/* Look up pre-sorted antibanding_type table by current MCC. */
static camera_antibanding_type camera_get_location(void) {
char value[PROP_VALUE_MAX];
char country_value[PROP_VALUE_MAX];
uint32_t country_code, count;
memset(value, 0x00, sizeof(value));
memset(country_value, 0x00, sizeof(country_value));
if (!__system_property_get("gsm.operator.numeric", value)) {
return CAMERA_ANTIBANDING_60HZ;
}
memcpy(country_value, value, 3);
country_code = atoi(country_value);
ALOGD("value:%s, country value:%s, country code:%d\n",
value, country_value, country_code);
int left = 0;
int right = country_number - 1;
while (left <= right) {
int index = (left + right) >> 1;
if (country_numeric[index].country_code == country_code)
return country_numeric[index].type;
else if (country_numeric[index].country_code > country_code)
right = index - 1;
else
left = index + 1;
}
return CAMERA_ANTIBANDING_60HZ;
}
// from camera.h, led_mode_t
static const str_map flash[] = {
{ CameraParameters::FLASH_MODE_OFF, LED_MODE_OFF },
{ CameraParameters::FLASH_MODE_AUTO, LED_MODE_AUTO },
{ CameraParameters::FLASH_MODE_ON, LED_MODE_ON },
{ CameraParameters::FLASH_MODE_TORCH, LED_MODE_TORCH }
};
// from mm-camera/common/camera.h.
static const str_map iso[] = {
{ CameraParameters::ISO_AUTO, CAMERA_ISO_AUTO},
{ CameraParameters::ISO_HJR, CAMERA_ISO_DEBLUR},
{ CameraParameters::ISO_100, CAMERA_ISO_100},
{ CameraParameters::ISO_200, CAMERA_ISO_200},
{ CameraParameters::ISO_400, CAMERA_ISO_400},
{ CameraParameters::ISO_800, CAMERA_ISO_800 },
{ CameraParameters::ISO_1600, CAMERA_ISO_1600 }
};
#define DONT_CARE 0
static const str_map focus_modes[] = {
{ CameraParameters::FOCUS_MODE_AUTO, AF_MODE_AUTO},
{ CameraParameters::FOCUS_MODE_INFINITY, DONT_CARE },
{ CameraParameters::FOCUS_MODE_NORMAL, AF_MODE_NORMAL },
{ CameraParameters::FOCUS_MODE_MACRO, AF_MODE_MACRO },
{ CameraParameters::FOCUS_MODE_CONTINUOUS_VIDEO, DONT_CARE }
};
static const str_map lensshade[] = {
{ CameraParameters::LENSSHADE_ENABLE, TRUE },
{ CameraParameters::LENSSHADE_DISABLE, FALSE }
};
static const str_map histogram[] = {
{ CameraParameters::HISTOGRAM_ENABLE, TRUE },
{ CameraParameters::HISTOGRAM_DISABLE, FALSE }
};
static const str_map skinToneEnhancement[] = {
{ CameraParameters::SKIN_TONE_ENHANCEMENT_ENABLE, TRUE },
{ CameraParameters::SKIN_TONE_ENHANCEMENT_DISABLE, FALSE }
};
static const str_map continuous_af[] = {
{ CameraParameters::CONTINUOUS_AF_OFF, FALSE },
{ CameraParameters::CONTINUOUS_AF_ON, TRUE }
};
static const str_map selectable_zone_af[] = {
{ CameraParameters::SELECTABLE_ZONE_AF_AUTO, AUTO },
{ CameraParameters::SELECTABLE_ZONE_AF_SPOT_METERING, SPOT },
{ CameraParameters::SELECTABLE_ZONE_AF_CENTER_WEIGHTED, CENTER_WEIGHTED },
{ CameraParameters::SELECTABLE_ZONE_AF_FRAME_AVERAGE, AVERAGE }
};
static const str_map facedetection[] = {
{ CameraParameters::FACE_DETECTION_OFF, FALSE },
{ CameraParameters::FACE_DETECTION_ON, TRUE }
};
#define DONT_CARE_COORDINATE -1
static const str_map touchafaec[] = {
{ CameraParameters::TOUCH_AF_AEC_OFF, FALSE },
{ CameraParameters::TOUCH_AF_AEC_ON, TRUE }
};
struct SensorType {
const char *name;
int rawPictureWidth;
int rawPictureHeight;
bool hasAutoFocusSupport;
int max_supported_snapshot_width;
int max_supported_snapshot_height;
int bitMask;
};
/*
* Values based on aec.c
*/
#define CAMERA_HISTOGRAM_ENABLE 1
#define CAMERA_HISTOGRAM_DISABLE 0
#define HISTOGRAM_STATS_SIZE 257
#define EXPOSURE_COMPENSATION_MAXIMUM_NUMERATOR 12
#define EXPOSURE_COMPENSATION_MINIMUM_NUMERATOR -12
#define EXPOSURE_COMPENSATION_DEFAULT_NUMERATOR 0
#define EXPOSURE_COMPENSATION_DENOMINATOR 6
#define EXPOSURE_COMPENSATION_STEP ((float (1))/EXPOSURE_COMPENSATION_DENOMINATOR)
static SensorType sensorTypes[] = {
{ "12mp", 5464, 3120, true, 4000, 3000,0x00001fff },
{ "12mp_sn12m0pz",4032, 3024, true, 4000, 3000,0x00000fff },
{ "5mp", 2608, 1960, true, 2592, 1944,0x00000fff },
{ "5mp_triumph", 5184, 1944, false, 2592, 1944,0x00000fff },
{ "3mp", 2064, 1544, false, 2048, 1536,0x000007ff },
{ "2mp", 3200, 1200, false, 1600, 1200,0x000007ff },
{ "mt9m113", 1280, 1024, false, 1280, 1024, 0x000000ff }, //TouchPad Camera Sensor
{ "ov7692", 640, 480, false, 640, 480, 0x000000ff } }; //Web Camera
static SensorType * sensorType;
static const str_map picture_formats[] = {
{CameraParameters::PIXEL_FORMAT_JPEG, PICTURE_FORMAT_JPEG},
{CameraParameters::PIXEL_FORMAT_RAW, PICTURE_FORMAT_RAW}
};
static const str_map frame_rate_modes[] = {
{CameraParameters::KEY_PREVIEW_FRAME_RATE_AUTO_MODE, FPS_MODE_AUTO},
{CameraParameters::KEY_PREVIEW_FRAME_RATE_FIXED_MODE, FPS_MODE_FIXED}
};
static int mPreviewFormat;
static const str_map preview_formats[] = {
{CameraParameters::PIXEL_FORMAT_YUV420SP, CAMERA_YUV_420_NV21},
{CameraParameters::PIXEL_FORMAT_YUV420SP_ADRENO, CAMERA_YUV_420_NV21_ADRENO}
};
static bool parameter_string_initialized = false;
static String8 preview_size_values;
static String8 picture_size_values;
static String8 fps_ranges_supported_values;
static String8 jpeg_thumbnail_size_values;
static String8 antibanding_values;
static String8 effect_values;
static String8 autoexposure_values;
static String8 whitebalance_values;
static String8 flash_values;
static String8 focus_mode_values;
static String8 iso_values;
static String8 lensshade_values;
static String8 histogram_values;
static String8 skinToneEnhancement_values;
static String8 touchafaec_values;
static String8 picture_format_values;
static String8 scenemode_values;
static String8 continuous_af_values;
static String8 zoom_ratio_values;
static String8 preview_frame_rate_values;
static String8 frame_rate_mode_values;
static String8 scenedetect_values;
static String8 preview_format_values;
static String8 selectable_zone_af_values;
static String8 facedetection_values;
static String8 create_sizes_str(const camera_size_type *sizes, int len) {
String8 str;
char buffer[32];
if (len > 0) {
snprintf(buffer, sizeof(buffer), "%dx%d", sizes[0].width, sizes[0].height);
str.append(buffer);
}
for (int i = 1; i < len; i++) {
snprintf(buffer, sizeof(buffer), ",%dx%d", sizes[i].width, sizes[i].height);
str.append(buffer);
}
return str;
}
static String8 create_fps_str(const android:: FPSRange* fps, int len) {
String8 str;
char buffer[32];
if (len > 0) {
snprintf(buffer, sizeof(buffer), "(%d,%d)", fps[0].minFPS, fps[0].maxFPS);
str.append(buffer);
}
for (int i = 1; i < len; i++) {
snprintf(buffer, sizeof(buffer), ",(%d,%d)", fps[i].minFPS, fps[i].maxFPS);
str.append(buffer);
}
return str;
}
static String8 create_values_str(const str_map *values, int len) {
String8 str;
if (len > 0) {
str.append(values[0].desc);
}
for (int i = 1; i < len; i++) {
str.append(",");
str.append(values[i].desc);
}
return str;
}
static String8 create_str(int16_t *arr, int length){
String8 str;
char buffer[32];
if(length > 0){
snprintf(buffer, sizeof(buffer), "%d", arr[0]);
str.append(buffer);
}
for (int i =1;i<length;i++){
snprintf(buffer, sizeof(buffer), ",%d",arr[i]);
str.append(buffer);
}
return str;
}
static String8 create_values_range_str(int min, int max){
String8 str;
char buffer[32];
if(min <= max){
snprintf(buffer, sizeof(buffer), "%d", min);
str.append(buffer);
for (int i = min + 1; i <= max; i++) {
snprintf(buffer, sizeof(buffer), ",%d", i);
str.append(buffer);
}
}
return str;
}
extern "C" {
//------------------------------------------------------------------------
// : 720p busyQ funcitons
// --------------------------------------------------------------------
static struct fifo_queue g_busy_frame_queue =
{0, 0, 0, PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, "frame_queue"};
};
/*===========================================================================
* FUNCTION cam_frame_wait_video
*
* DESCRIPTION this function waits a video in the busy queue
* ===========================================================================*/
static void cam_frame_wait_video (void)
{
ALOGV("cam_frame_wait_video E ");
if ((g_busy_frame_queue.num_of_frames) <=0){
pthread_cond_wait(&(g_busy_frame_queue.wait), &(g_busy_frame_queue.mut));
}
ALOGV("cam_frame_wait_video X");
return;
}
/*===========================================================================
* FUNCTION cam_frame_flush_video
*
* DESCRIPTION this function deletes all the buffers in busy queue
* ===========================================================================*/
void cam_frame_flush_video (void)
{
ALOGV("cam_frame_flush_video: in n = %d\n", g_busy_frame_queue.num_of_frames);
pthread_mutex_lock(&(g_busy_frame_queue.mut));
while (g_busy_frame_queue.front)
{
//dequeue from the busy queue
struct fifo_node *node = dequeue (&g_busy_frame_queue);
if(node)
free(node);
ALOGV("cam_frame_flush_video: node \n");
}
pthread_mutex_unlock(&(g_busy_frame_queue.mut));
ALOGV("cam_frame_flush_video: out n = %d\n", g_busy_frame_queue.num_of_frames);
return ;
}
/*===========================================================================
* FUNCTION cam_frame_get_video
*
* DESCRIPTION this function returns a video frame from the head
* ===========================================================================*/
static struct msm_frame * cam_frame_get_video()
{
struct msm_frame *p = NULL;
ALOGV("cam_frame_get_video... in\n");
ALOGV("cam_frame_get_video... got lock\n");
if (g_busy_frame_queue.front)
{
//dequeue
struct fifo_node *node = dequeue (&g_busy_frame_queue);
if (node)
{
p = (struct msm_frame *)node->f;
free (node);
}
ALOGV("cam_frame_get_video... out = %lx\n", p->buffer);
}
return p;
}
/*===========================================================================
* FUNCTION cam_frame_post_video
*
* DESCRIPTION this function add a busy video frame to the busy queue tails
* ===========================================================================*/
static void cam_frame_post_video (struct msm_frame *p)
{
if (!p)
{
ALOGE("post video , buffer is null");
return;
}
ALOGV("cam_frame_post_video... in = %x\n", (unsigned int)(p->buffer));
pthread_mutex_lock(&(g_busy_frame_queue.mut));
ALOGV("post_video got lock. q count before enQ %d", g_busy_frame_queue.num_of_frames);
//enqueue to busy queue
struct fifo_node *node = (struct fifo_node *)malloc (sizeof (struct fifo_node));
if (node)
{
ALOGV(" post video , enqueing in busy queue");
node->f = p;
node->next = NULL;
enqueue (&g_busy_frame_queue, node);
ALOGV("post_video got lock. q count after enQ %d", g_busy_frame_queue.num_of_frames);
}
else
{
ALOGE("cam_frame_post_video error... out of memory\n");
}
pthread_mutex_unlock(&(g_busy_frame_queue.mut));
pthread_cond_signal(&(g_busy_frame_queue.wait));
ALOGV("cam_frame_post_video... out = %lx\n", p->buffer);
return;
}
void QualcommCameraHardware::storeTargetType(void) {
char mDeviceName[PROPERTY_VALUE_MAX];
property_get("ro.board.platform",mDeviceName," ");
ALOGV("Searching for target type %s", mDeviceName);
mCurrentTarget = TARGET_MAX;
for( int i = 0; i < TARGET_MAX ; i++) {