aboutsummaryrefslogtreecommitdiff
path: root/en/devices/camera/camera3_3Amodes.html
blob: ab3a5b597596c1a3713d7731840400c834778496 (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
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
<html devsite>
  <head>
    <title>3A Modes and State Transition</title>
    <meta name="project_path" value="/_project.yaml" />
    <meta name="book_path" value="/_book.yaml" />
  </head>
  <body>
  <!--
      Copyright 2017 The Android Open Source Project

      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.
  -->



<p>
  While the actual 3A algorithms are up to the HAL implementation, a high-level
  state machine description is defined by the HAL interface to allow the HAL
  device and the framework to communicate about the current state of 3A and
  trigger 3A events.</p>
<p>When the device is opened, all the individual 3A states must be
  STATE_INACTIVE.
  Stream configuration does not reset 3A. For example, locked focus must be
  maintained across the <code>configure()</code> call.</p>
<p>Triggering a 3A action involves simply setting the relevant trigger entry in
  the settings for the next request to indicate start of trigger. For example,
  the trigger for starting an autofocus scan is setting the entry
  ANDROID_CONTROL_AF_TRIGGER to ANDROID_CONTROL_AF_TRIGGER_START for one request;
  and cancelling an autofocus scan is triggered by setting
  ANDROID_CONTROL_AF_TRIGGER to ANDROID_CONTRL_AF_TRIGGER_CANCEL. Otherwise, the
  entry will not exist or be set to ANDROID_CONTROL_AF_TRIGGER_IDLE. Each
  request with a trigger entry set to a non-IDLE value will be treated as an
  independent triggering event.</p>
<p>At the top level, 3A is controlled by the ANDROID_CONTROL_MODE setting. It
  selects between no 3A (ANDROID_CONTROL_MODE_OFF), normal AUTO mode
  (ANDROID_CONTROL_MODE_AUTO), and using the scene mode setting
  (ANDROID_CONTROL_USE_SCENE_MODE):</p>
<ul>
  <li>In OFF mode, each of the individual auto-focus (AF), auto-exposure (AE),
    and auto-whitebalance (AWB) modes are effectively OFF, and none of the
    capture controls may be overridden by the 3A routines.</li>
  <li>In AUTO mode, AF, AE, and AWB modes all run their own independent
    algorithms, and have their own mode, state, and trigger metadata entries,
    as listed in the next section.</li>
  <li>In USE_SCENE_MODE, the value of the ANDROID_CONTROL_SCENE_MODE entry must
    be used to determine the behavior of 3A routines. In SCENE_MODEs other than
    FACE_PRIORITY, the HAL must override the values of
    ANDROID_CONTROL_AE/AWB/AF_MODE to be the mode it prefers for the selected
    SCENE_MODE. For example, the HAL may prefer SCENE_MODE_NIGHT to use
    CONTINUOUS_FOCUS AF mode. Any user selection of AE/AWB/AF_MODE when scene
    must be ignored for these scene modes.</li>
  <li>For SCENE_MODE_FACE_PRIORITY, the AE/AWB/AFMODE controls work as in
    ANDROID_CONTROL_MODE_AUTO, but the 3A routines must bias toward metering and
    focusing on any detected faces in the scene.</li>
</ul>

<h2 id="auto-focus">Auto-focus settings and result entries</h2>

<table>
  <tr>
    <th colspan="2">Main metadata entries</th>
  </tr>
  <tr class="alt">
    <td>ANDROID_CONTROL_AF_MODE</td>
    <td>Control for selecting the current autofocus mode. Set by the framework
      in the request settings.</td>
  </tr>
  <tr>
    <td>AF_MODE_OFF</td>
    <td>AF is disabled; the framework/app directly controls lens position.</td>
  </tr>
  <tr>
    <td>AF_MODE_AUTO</td>
    <td>Single-sweep autofocus. No lens movement unless AF is triggered.</td>
  </tr>
  <tr>
    <td>AF_MODE_MACRO</td>
    <td>Single-sweep up-close autofocus. No lens movement unless AF is triggered</td>
  </tr>
  <tr>
    <td>AF_MODE_CONTINUOUS_VIDEO</td>
    <td>Smooth continuous focusing, for recording video. Triggering immediately
    locks focus in current position. Canceling resumes continuous focusing.</td>
  </tr>
  <tr>
    <td>AF_MODE_CONTINUOUS_PICTURE</td>
    <td>Fast continuous focusing, for zero-shutter-lag still capture. Triggering
      locks focus once currently active sweep concludes. Canceling resumes
      continuous focusing.</td>
  </tr>
  <tr>
    <td>AF_MODE_EDOF</td>
    <td>Advanced extended depth of field focusing. There is no autofocus scan,
      so triggering one or canceling one has no effect. Images are focused
      automatically by the HAL.</td>
  </tr>
  <tr class="alt">
    <td>ANDROID_CONTROL_AF_STATE</td>
    <td>Dynamic metadata describing the current AF algorithm state, reported
      by the HAL in the result metadata.</td>
  </tr>
  <tr>
    <td>AF_STATE_INACTIVE</td>
    <td>No focusing has been done, or algorithm was reset. Lens is not moving.
      Always the state for MODE_OFF or MODE_EDOF. When the device is opened,
      it must start in this state.</td>
  </tr>
  <tr>
    <td>AF_STATE_PASSIVE_SCAN</td>
    <td>A continuous focus algorithm is currently scanning for good focus.
      The lens is moving.</td>
  </tr>
  <tr>
    <td>AF_STATE_PASSIVE_FOCUSED</td>
    <td>A continuous focus algorithm believes it is well focused. The lens
      is not moving. The HAL may spontaneously leave this state.</td>
  </tr>
  <tr>
    <td>AF_STATE_PASSIVE_UNFOCUSED</td>
    <td>A continuous focus algorithm believes it is not well focused. The lens
      is not moving. The HAL may spontaneously leave this state.</td>
  </tr>
  <tr>
    <td>AF_STATE_ACTIVE_SCAN</td>
    <td>A scan triggered by the user is underway.</td>
  </tr>
  <tr>
    <td>AF_STATE_FOCUSED_LOCKED</td>
    <td>The AF algorithm believes it is focused. The lens is not moving.</td>
  </tr>
  <tr>
    <td>AF_STATE_NOT_FOCUSED_LOCKED</td>
    <td>The AF algorithm has been unable to focus. The lens is not moving.</td>
  </tr>
  <tr class="alt">
    <td>ANDROID_CONTROL_AFTRIGGER</td>
    <td>Control for starting an autofocus scan, the meaning of which depends on
    mode and state. Set by the framework in the request settings.</td>
  </tr>
  <tr>
    <td>AF_TRIGGER_IDLE</td>
    <td>No current trigger.</td>
  </tr>
  <tr>
    <td>AF_TRIGGER_START</td>
    <td>Trigger start of AF scan. Effect depends on mode and state.</td>
  </tr>
  <tr>
    <td>AF_TRIGGER_CANCEL</td>
    <td>Cancel current AF scan if any, and reset algorithm to default.</td>
  </tr>
</table>

<table>
  <tr>
    <th colspan="2">Additional metadata entries</th>
  </tr>
  <tr class="alt">
    <td>ANDROID_CONTROL_AF_REGIONS</td>
    <td>Control for selecting the regions of the field of view (FOV) that should
      be used to determine good focus. This applies to all AF
    modes that scan for focus. Set by the framework in the request settings.</td>
  </tr>
</table>

<h2 id="auto-exposure">Auto-exposure settings and result entries</h2>

<table>
  <th colspan="2">Main metadata entries</th>
  <tr class="alt">
    <td>ANDROID_CONTROL_AE_MODE</td>
    <td>Control for selecting the current auto-exposure mode. Set by the
      framework in the request settings.</td>
  </tr>
  <tr>
    <td>AE_MODE_OFF</td>
    <td>Autoexposure is disabled; the user controls exposure, gain, frame
      duration, and flash.</td>
  </tr>
  <tr>
    <td>AE_MODE_ON</td>
    <td>Standard autoexposure, with flash control disabled. User may set flash
      to fire or to torch mode.</td>
  </tr>
  <tr>
    <td>AE_MODE_ON_AUTO_FLASH</td>
    <td>Standard autoexposure, with flash on at HAL's discretion for precapture
      and still capture. User control of flash disabled.</td>
  </tr>
  <tr>
    <td>AE_MODE_ON_ALWAYS_FLASH</td>
    <td>Standard autoexposure, with flash always fired for capture, and at HAL's
    discretion for precapture. User control of flash disabled.</td>
  </tr>
  <tr>
    <td>AE_MODE_ON_AUTO_FLASH_REDEYE</td>
    <td>Standard autoexposure, with flash on at HAL's discretion for precapture
      and still capture. Use a flash burst at end of precapture sequence to
      reduce redeye in the final picture. User control of flash disabled.</td>
  </tr>
  <tr class="alt">
    <td>ANDROID_CONTROL_AE_STATE</td>
    <td>Dynamic metadata describing the current AE algorithm state, reported by
      the HAL in the result metadata.</td>
  </tr>
  <tr>
    <td>AE_STATE_INACTIVE</td>
    <td>Initial AE state after mode switch. When the device is opened, it must
      start in this state.</td>
  </tr>
  <tr>
    <td>AE_STATE_SEARCHING</td>
    <td>AE is not converged to a good value and is adjusting exposure
      parameters.</td>
  </tr>
  <tr>
    <td>AE_STATE_CONVERGED</td>
    <td>AE has found good exposure values for the current scene, and the
      exposure parameters are not changing. HAL may spontaneously leave this
      state to search for a better solution.</td>
  </tr>
  <tr>
    <td>AE_STATE_LOCKED</td>
    <td>AE has been locked with the AE_LOCK control. Exposure values are not
      changing.</td>
  </tr>
  <tr>
    <td>AE_STATE_FLASH_REQUIRED</td>
    <td>The HAL has converged exposure but believes flash is required for a
      sufficiently bright picture. Used for determining if a zero-shutter-lag
      frame can be used.</td>
  </tr>
  <tr>
    <td>AE_STATE_PRECAPTURE</td>
    <td>The HAL is in the middle of a precapture sequence. Depending on AE mode,
      this mode may involve firing the flash for metering or a burst of flash
      pulses for redeye reduction.</td>
  </tr>
  <tr class="alt">
    <td>ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER</td>
    <td>Control for starting a metering sequence before capturing a high-quality
      image. Set by the framework in the request settings.</td>
  </tr>
  <tr>
    <td>PRECAPTURE_TRIGGER_IDLE</td>
    <td>No current trigger.</td>
  </tr>
  <tr>
    <td>PRECAPTURE_TRIGGER_START</td>
    <td>Start a precapture sequence. The HAL should use the subsequent requests
      to measure good exposure/white balance for an upcoming high-resolution
      capture.</td>
  </tr>
</table>

<table>
  <th colspan="2">Additional metadata entries</th>
  <tr class="alt">
    <td>ANDROID_CONTROL_AE_LOCK</td>
    <td>Control for locking AE controls to their current values.</td>
  </tr>
  <tr class="alt">
    <td>ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION</td>
    <td>Control for adjusting AE algorithm target brightness point.</td>
  </tr>
  <tr class="alt">
    <td>ANDROID_CONTROL_AE_TARGET_FPS_RANGE</td>
    <td>Control for selecting the target frame rate range for the AE algorithm.
      The AE routine cannot change the frame rate to be outside these
      bounds.</td>
  </tr>
  <tr class="alt">
    <td>ANDROID_CONTROL_AE_REGIONS</td>
    <td>Control for selecting the regions of the FOV that should be used to
      determine good exposure levels. This applies to all AE modes
      besides OFF.</td>
  </tr>
</table>

<h2 id="auto-wb">Auto-whitebalance settings and result entries</h2>

<table>
  <th colspan="2">Main metadata entries</th>
  <tr class="alt">
    <td>ANDROID_CONTROL_AWB_MODE</td>
    <td>Control for selecting the current white-balance mode.</td>
  </tr>
  <tr>
    <td>AWB_MODE_OFF</td>
    <td>Auto-whitebalance is disabled. User controls color matrix.</td>
  </tr>
  <tr>
    <td>AWB_MODE_AUTO</td>
    <td>Automatic white balance is enabled; 3A controls color transform,
    possibly using more complex transforms than a simple matrix.</td>
  </tr>
  <tr>
    <td>AWB_MODE_INCANDESCENT</td>
    <td>Fixed white balance settings good for indoor incandescent (tungsten)
    lighting, roughly 2700K.</td>
  </tr>
  <tr>
    <td>AWB_MODE_FLUORESCENT</td>
    <td>Fixed white balance settings good for fluorescent lighting, roughly
    5000K.</td>
  </tr>
  <tr>
    <td>AWB_MODE_WARM_FLUORESCENT</td>
    <td>Fixed white balance settings good for fluorescent lighting, roughly
    3000K.</td>
  </tr>
  <tr>
    <td>AWB_MODE_DAYLIGHT</td>
    <td>Fixed white balance settings good for daylight, roughly 5500K.</td>
  </tr>
  <tr>
    <td>AWB_MODE_CLOUDY_DAYLIGHT</td>
    <td>Fixed white balance settings good for clouded daylight, roughly 6500K.</td>
  </tr>
  <tr>
    <td>AWB_MODE_TWILIGHT</td>
    <td>Fixed white balance settings good for near-sunset/sunrise, roughly
    15000K.</td>
  </tr>
  <tr>
    <td>AWB_MODE_SHADE</td>
    <td>Fixed white balance settings good for areas indirectly lit by the sun,
    roughly 7500K.</td>
  </tr>
  <tr class="alt">
    <td>ANDROID_CONTROL_AWB_STATE</td>
    <td>Dynamic metadata describing the current AWB algorithm state, reported by
    the HAL in the result metadata.</td>
  </tr>
  <tr>
    <td>AWB_STATE_INACTIVE</td>
    <td>Initial AWB state after mode switch. When the device is opened, it must
    start in this state.</td>
  </tr>
  <tr>
    <td>AWB_STATE_SEARCHING</td>
    <td>AWB is not converged to a good value and is changing color adjustment
    parameters.</td>
  </tr>
  <tr>
    <td>AWB_STATE_CONVERGED</td>
    <td>AWB has found good color adjustment values for the current scene, and
      the parameters are not changing. HAL may spontaneously leave this state
    to search for a better solution.</td>
  </tr>
  <tr>
    <td>AWB_STATE_LOCKED</td>
    <td>AWB has been locked with the AWB_LOCK control. Color adjustment
    values are not changing.</td>
  </tr>
</table>

<table>
  <th colspan="2">Additional metadata entries</th>
  <tr class="alt">
    <td>ANDROID_CONTROL_AWB_LOCK</td>
    <td>Control for locking AWB color adjustments to their current values.</td>
  </tr>
  <tr class="alt">
    <td>ANDROID_CONTROL_AWB_REGIONS</td>
    <td>Control for selecting the regions of the FOV that should be used to
      determine good color balance. This applies only to auto-whitebalance
      mode.</td>
  </tr>
</table>

<h2 id="state-transition">General state machine transition notes</h2>
<p>Switching between AF, AE, or AWB modes always resets the algorithm's state to
  INACTIVE. Similarly, switching between CONTROL_MODE or CONTROL_SCENE_MODE if
  CONTROL_MODE == USE_SCENE_MODE resets all the algorithm states to INACTIVE.</p>
<p>The tables below are per-mode.</p>

<h2 id="af-state">AF state machines</h2>

<table>
  <tr>
  <th colspan="4">mode = AF_MODE_OFF or AF_MODE_EDOF</th></tr>
  <tr class="alt">
    <td>State</td>
    <td>Transformation cause</td>
    <td>New state</td>
    <td>Notes</td>
  </tr>
  <tr>
    <td>INACTIVE</td>
    <td></td>
    <td></td>
    <td>AF is disabled</td>
  </tr>
</table>

<table>
  <tr>
  <th colspan="4">mode = AF_MODE_AUTO or AF_MODE_MACRO</th></tr>
  <tr class="alt">
    <td>State</td>
    <td>Transformation cause</td>
    <td>New state</td>
    <td>Notes</td>
  </tr>
  <tr>
    <td>INACTIVE</td>
    <td>AF_TRIGGER</td>
    <td>ACTIVE_SCAN</td>
    <td><p>Start AF sweep</p>
      <p>Lens now moving</p></td>
  </tr>
  <tr>
    <td>ACTIVE_SCAN</td>
    <td>AF sweep done</td>
    <td>FOCUSED_LOCKED</td>
    <td><p>If AF successful</p>
      <p>Lens now locked</p></td>
  </tr>
  <tr>
    <td>ACTIVE_SCAN</td>
    <td>AF sweep done</td>
    <td>NOT_FOCUSED_LOCKED</td>
    <td><p>If AF successful</p>
      <p>Lens now locked</p></td>
  </tr>
  <tr>
    <td>ACTIVE_SCAN</td>
    <td>AF_CANCEL</td>
    <td>INACTIVE</td>
    <td><p>Cancel/reset AF</p>
      <p>Lens now locked</p></td>
  </tr>
  <tr>
    <td>FOCUSED_LOCKED</td>
    <td>AF_CANCEL</td>
    <td>INACTIVE</td>
    <td>Cancel/reset AF</td>
  </tr>
  <tr>
    <td>FOCUSED_LOCKED</td>
    <td>AF_TRIGGER</td>
    <td>ACTIVE_SCAN</td>
    <td><p>Start new sweep</p>
      <p>Lens now moving</p></td>
  </tr>
  <tr>
    <td>NOT_FOCUSED_LOCKED</td>
    <td>AF_CANCEL</td>
    <td>INACTIVE</td>
    <td>Cancel/reset AF</td>
  </tr>
  <tr>
    <td>NOT_FOCUSED_LOCKED</td>
    <td>AF_TRIGGER</td>
    <td>ACTIVE_SCAN</td>
    <td><p>Start new sweep</p>
      <p>Lens now moving</p></td>
  </tr>
  <tr>
    <td>All states</td>
    <td>Mode change</td>
    <td>INACTIVE</td>
    <td></td>
  </tr>
</table>

<table>
  <tr>
  <th colspan="4">mode = AF_MODE_CONTINUOUS_VIDEO</th></tr>
  <tr class="alt">
    <td>State</td>
    <td>Transformation cause</td>
    <td>New state</td>
    <td>Notes</td>
  </tr>
  <tr>
    <td>INACTIVE</td>
    <td>HAL initiates new scan</td>
    <td>PASSIVE_SCAN</td>
    <td><p>Start AF sweep</p>
      <p>Lens now moving</p></td>
  </tr>
  <tr>
    <td>INACTIVE</td>
    <td>AF_TRIGGER</td>
    <td>NOT_FOCUSED_LOCKED</td>
    <td><p>AF state query</p>
      <p>Lens now locked</p></td>
  </tr>
  <tr>
    <td>PASSIVE_SCAN</td>
    <td>HAL completes current scan</td>
    <td>PASSIVE_FOCUSED</td>
    <td><p>End AF scan</p>
      <p>Lens now locked</p></td>
  </tr>
  <tr>
    <td>PASSIVE_SCAN</td>
    <td>AF_TRIGGER</td>
    <td>FOCUSED_LOCKED</td>
    <td><p>Immediate transformation
      if focus is good</p>
      <p>Lens now locked</p></td>
  </tr>
  <tr>
    <td>PASSIVE_SCAN</td>
    <td>AF_TRIGGER</td>
    <td>NOT_FOCUSED_LOCKED</td>
    <td><p>Immediate transformation
      if focus is bad</p>
      <p>Lens now locked</p></td>
  </tr>
  <tr>
    <td>PASSIVE_SCAN</td>
    <td>AF_CANCEL</td>
    <td>INACTIVE</td>
    <td><p>Reset lens position</p>
      <p>Lens now locked</p></td>
  </tr>
  <tr>
    <td>PASSIVE_FOCUSED</td>
    <td>HAL initiates new scan</td>
    <td>PASSIVE_SCAN</td>
    <td><p>Start AF scan</p>
      <p>Lens now moving</p></td>
  </tr>
  <tr>
    <td>PASSIVE_FOCUSED</td>
    <td>AF_TRIGGER</td>
    <td>FOCUSED_LOCKED</td>
    <td><p>Immediate transformation
      if focus is good</p>
      <p>Lens now locked</p></td>
  </tr>
  <tr>
    <td>PASSIVE_FOCUSED</td>
    <td>AF_TRIGGER</td>
    <td>NOT_FOCUSED_LOCKED</td>
    <td>Immediate transformation
      if focus is bad
      <p>Lens now locked</p></td>
  </tr>
  <tr>
    <td>FOCUSED_LOCKED</td>
    <td>AF_TRIGGER</td>
    <td>FOCUSED_LOCKED</td>
    <td>No effect</td>
  </tr>
  <tr>
    <td>FOCUSED_LOCKED</td>
    <td>AF_CANCEL</td>
    <td>INACTIVE</td>
    <td>Restart AF scan</td>
  </tr>
  <tr>
    <td>NOT_FOCUSED_LOCKED</td>
    <td>AF_TRIGGER</td>
    <td>NOT_FOCUSED_LOCKED</td>
    <td>No effect</td>
  </tr>
  <tr>
    <td>NOT_FOCUSED_LOCKED</td>
    <td>AF_CANCEL</td>
    <td>INACTIVE</td>
    <td>Restart AF scan</td>
  </tr>
</table>

<table>
  <tr>
  <th colspan="4">mode = AF_MODE_CONTINUOUS_PICTURE</th></tr>
  <tr class="alt">
    <td>State</td>
    <td>Transformation cause</td>
    <td>New state</td>
    <td>Notes</td>
  </tr>
  <tr>
    <td>INACTIVE</td>
    <td>HAL initiates new scan</td>
    <td>PASSIVE_SCAN</td>
    <td><p>Start AF scan</p>
      <p>Lens now moving</p></td>
  </tr>
  <tr>
    <td>INACTIVE</td>
    <td>AF_TRIGGER</td>
    <td>NOT_FOCUSED_LOCKED</td>
    <td><p>AF state query</p>
      <p>Lens now locked</p></td>
  </tr>
  <tr>
    <td>PASSIVE_SCAN</td>
    <td>HAL completes current scan</td>
    <td>PASSIVE_FOCUSED</td>
    <td>End AF scan
      <p>Lens now locked</p></td>
  </tr>
  <tr>
    <td>PASSIVE_SCAN</td>
    <td>AF_TRIGGER</td>
    <td>FOCUSED_LOCKED</td>
    <td><p>Eventual transformation once focus good</p>
      <p>Lens now locked</p></td>
  </tr>
  <tr>
    <td>PASSIVE_SCAN</td>
    <td>AF_TRIGGER</td>
    <td>NOT_FOCUSED_LOCKED</td>
    <td><p>Eventual transformation if cannot focus</p>
      <p>Lens now locked</p></td>
  </tr>
  <tr>
    <td>PASSIVE_SCAN</td>
    <td>AF_CANCEL</td>
    <td>INACTIVE</td>
    <td><p>Reset lens position</p>
      <p>Lens now locked</p></td>
  </tr>
  <tr>
    <td>PASSIVE_FOCUSED</td>
    <td>HAL initiates new scan</td>
    <td>PASSIVE_SCAN</td>
    <td><p>Start AF scan</p>
      <p>Lens now moving</p></td>
  </tr>
  <tr>
    <td>PASSIVE_FOCUSED</td>
    <td>AF_TRIGGER</td>
    <td>FOCUSED_LOCKED</td>
    <td><p>Immediate transformation if focus is good</p>
      <p>Lens now locked</p></td>
  </tr>
  <tr>
    <td>PASSIVE_FOCUSED</td>
    <td>AF_TRIGGER</td>
    <td>NOT_FOCUSED_LOCKED</td>
    <td><p>Immediate transformation if focus is bad</p>
      <p>Lens now locked</p></td>
  </tr>
  <tr>
    <td>FOCUSED_LOCKED</td>
    <td>AF_TRIGGER</td>
    <td>FOCUSED_LOCKED</td>
    <td>No effect</td>
  </tr>
  <tr>
    <td>FOCUSED_LOCKED</td>
    <td>AF_CANCEL</td>
    <td>INACTIVE</td>
    <td>Restart AF scan</td>
  </tr>
  <tr>
    <td>NOT_FOCUSED_LOCKED</td>
    <td>AF_TRIGGER</td>
    <td>NOT_FOCUSED_LOCKED</td>
    <td>No effect</td>
  </tr>
  <tr>
    <td>NOT_FOCUSED_LOCKED</td>
    <td>AF_CANCEL</td>
    <td>INACTIVE</td>
    <td>Restart AF scan</td>
  </tr>
</table>

<h2 id="ae-wb">AE and AWB state machines</h2>
<p>The AE and AWB state machines are mostly identical. AE has additional
  FLASH_REQUIRED and PRECAPTURE states. So rows below that refer to those two
  states should be ignored for the AWB state machine.</p>


<table>
  <tr>
  <th colspan="4">mode = AE_MODE_OFF / AWB mode not AUTO</th></tr>
  <tr class="alt">
    <td>State</td>
    <td>Transformation cause</td>
    <td>New state</td>
    <td>Notes</td>
  </tr>
  <tr>
    <td>INACTIVE</td>
    <td></td>
    <td></td>
    <td>AE/AWB disabled</td>
  </tr>
</table>

<table>
  <tr>
  <th colspan="4">mode = AE_MODE_ON_* / AWB_MODE_AUTO</th></tr>
  <tr class="alt">
    <td>State</td>
    <td>Transformation cause</td>
    <td>New state</td>
    <td>Notes</td>
  </tr>
  <tr>
    <td>INACTIVE</td>
    <td>HAL initiates AE/AWB scan</td>
    <td>SEARCHING</td>
    <td></td>
  </tr>
  <tr>
    <td>INACTIVE</td>
    <td>AE/AWB_LOCK on</td>
    <td>LOCKED</td>
    <td>Values locked</td>
  </tr>
  <tr>
    <td>SEARCHING</td>
    <td>HAL finishes AE/AWB scan</td>
    <td>CONVERGED</td>
    <td>Good values, not changing</td>
  </tr>
  <tr>
    <td>SEARCHING</td>
    <td>HAL finishes AE scan</td>
    <td>FLASH_REQUIRED</td>
    <td>Converged but too dark without flash</td>
  </tr>
  <tr>
    <td>SEARCHING</td>
    <td>AE/AWB_LOCK on</td>
    <td>LOCKED</td>
    <td>Values locked</td>
  </tr>
  <tr>
    <td>CONVERGED</td>
    <td>HAL initiates AE/AWB scan</td>
    <td>SEARCHING</td>
    <td>Values locked</td>
  </tr>
  <tr>
    <td>CONVERGED</td>
    <td>AE/AWB_LOCK on</td>
    <td>LOCKED</td>
    <td>Values locked</td>
  </tr>
  <tr>
    <td>FLASH_REQUIRED</td>
    <td>HAL initiates AE/AWB scan</td>
    <td>SEARCHING</td>
    <td>Values locked</td>
  </tr>
  <tr>
    <td>FLASH_REQUIRED</td>
    <td>AE/AWB_LOCK on</td>
    <td>LOCKED</td>
    <td>Values locked</td>
  </tr>
  <tr>
    <td>LOCKED</td>
    <td>AE/AWB_LOCK off</td>
    <td>SEARCHING</td>
    <td>Values not good after unlock</td>
  </tr>
  <tr>
    <td>LOCKED</td>
    <td>AE/AWB_LOCK off</td>
    <td>CONVERGED</td>
    <td>Values good after unlock</td>
  </tr>
  <tr>
    <td>LOCKED</td>
    <td>AE_LOCK off</td>
    <td>FLASH_REQUIRED</td>
    <td>Exposure good, but too dark</td>
  </tr>
  <tr>
    <td>All AE states</td>
    <td>PRECAPTURE_START</td>
    <td>PRECAPTURE</td>
    <td>Start precapture sequence</td>
  </tr>
  <tr>
    <td>PRECAPTURE</td>
    <td>Sequence done, AE_LOCK off</td>
    <td>CONVERGED</td>
    <td>Ready for high-quality capture</td>
  </tr>
  <tr>
    <td>PRECAPTURE</td>
    <td>Sequence done, AE_LOCK on</td>
    <td>LOCKED</td>
    <td>Ready for high-quality capture</td>
  </tr>
</table>

<h2 id="manual-control">Enabling manual control</h2>
<p>Several controls are also involved in configuring the device 3A blocks to
  allow for direct application control.</p>
<p>The HAL model for 3A control is that for each request, the HAL inspects the
  state of the 3A control fields. If any 3A routine is enabled, then that
  routine overrides the control variables that relate to that routine, and
  these override values are then available in the result metadata for that
  capture. So for example, if auto-exposure is enabled in a request, the HAL
  should overwrite the exposure, gain, and frame duration fields (and
  potentially the flash fields, depending on AE mode) of the request. The
  list of relevant controls is:</p>

<table>
  <tr>
    <th>Control name</th>
    <th>Unit</th>
    <th>Notes</th>
  </tr>
  <tr>
    <td>android.control.mode</td>
    <td>enum: OFF, AUTO, USE_SCENE_MODE</td>
    <td>High-level 3A control. When set to OFF, all 3A control by the HAL is
      disabled. The application must set the fields for capture parameters
      itself. When set to AUTO, the individual algorithm controls in
      android.control.* are in effect, such as android.control.afMode.
      When set to USE_SCENE_MODE, the individual controls in android.control.*
      are mostly disabled, and the HAL implements one of the scene mode
      settings (such as ACTION, SUNSET, or PARTY) as it wishes.</td>
  </tr>
  <tr>
    <td>android.control.afMode</td>
    <td>enum</td>
    <td>OFF means manual control of lens
      focusing through android.lens.focusDistance.</td>
  </tr>
  <tr>
    <td>android.control.aeMode</td>
    <td>enum</td>
    <td>OFF means manual control of exposure/gain/frame duration through
      android.sensor.exposureTime / .sensitivity / .frameDuration</td>
  </tr>
  <tr>
    <td>android.control.awbMode</td>
    <td>enum</td>
    <td>OFF means manual control of white balance.</td>
  </tr>
</table>

  </body>
</html>