CameraHardwareInterface.h revision f67e23ef637d0b53a0d4bebb68c654234df3da94
1/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_HARDWARE_CAMERA_HARDWARE_INTERFACE_H
18#define ANDROID_HARDWARE_CAMERA_HARDWARE_INTERFACE_H
19
20#include <binder/IMemory.h>
21#include <binder/MemoryBase.h>
22#include <binder/MemoryHeapBase.h>
23#include <utils/RefBase.h>
24#include <ui/GraphicBuffer.h>
25#include <camera/Camera.h>
26#include <camera/CameraParameters.h>
27#include <system/window.h>
28#include <hardware/camera.h>
29
30namespace android {
31
32typedef void (*notify_callback)(int32_t msgType,
33                            int32_t ext1,
34                            int32_t ext2,
35                            void* user);
36
37typedef void (*data_callback)(int32_t msgType,
38                            const sp<IMemory> &dataPtr,
39                            camera_frame_metadata_t *metadata,
40                            void* user);
41
42typedef void (*data_callback_timestamp)(nsecs_t timestamp,
43                            int32_t msgType,
44                            const sp<IMemory> &dataPtr,
45                            void *user);
46
47/**
48 * CameraHardwareInterface.h defines the interface to the
49 * camera hardware abstraction layer, used for setting and getting
50 * parameters, live previewing, and taking pictures. It is used for
51 * HAL devices with version CAMERA_DEVICE_API_VERSION_1_0 only.
52 *
53 * It is a referenced counted interface with RefBase as its base class.
54 * CameraService calls openCameraHardware() to retrieve a strong pointer to the
55 * instance of this interface and may be called multiple times. The
56 * following steps describe a typical sequence:
57 *
58 *   -# After CameraService calls openCameraHardware(), getParameters() and
59 *      setParameters() are used to initialize the camera instance.
60 *   -# startPreview() is called.
61 *
62 * Prior to taking a picture, CameraService often calls autofocus(). When auto
63 * focusing has completed, the camera instance sends a CAMERA_MSG_FOCUS notification,
64 * which informs the application whether focusing was successful. The camera instance
65 * only sends this message once and it is up  to the application to call autoFocus()
66 * again if refocusing is desired.
67 *
68 * CameraService calls takePicture() to request the camera instance take a
69 * picture. At this point, if a shutter, postview, raw, and/or compressed
70 * callback is desired, the corresponding message must be enabled. Any memory
71 * provided in a data callback must be copied if it's needed after returning.
72 */
73
74class CameraHardwareInterface : public virtual RefBase {
75public:
76    CameraHardwareInterface(const char *name)
77    {
78        mDevice = 0;
79        mName = name;
80    }
81
82    ~CameraHardwareInterface()
83    {
84        ALOGI("Destroying camera %s", mName.string());
85        if(mDevice) {
86            int rc = mDevice->common.close(&mDevice->common);
87            if (rc != OK)
88                ALOGE("Could not close camera %s: %d", mName.string(), rc);
89        }
90    }
91
92    status_t initialize(hw_module_t *module)
93    {
94        ALOGI("Opening camera %s", mName.string());
95        camera_module_t *cameraModule = reinterpret_cast<camera_module_t *>(module);
96        camera_info info;
97        status_t res = cameraModule->get_camera_info(atoi(mName.string()), &info);
98        if (res != OK) return res;
99
100        int rc = OK;
101        if (module->module_api_version >= CAMERA_MODULE_API_VERSION_2_3 &&
102            info.device_version > CAMERA_DEVICE_API_VERSION_1_0) {
103            // Open higher version camera device as HAL1.0 device.
104            rc = cameraModule->open_legacy(module, mName.string(),
105                                               CAMERA_DEVICE_API_VERSION_1_0,
106                                               (hw_device_t **)&mDevice);
107        } else {
108            rc = CameraService::filterOpenErrorCode(module->methods->open(
109                module, mName.string(), (hw_device_t **)&mDevice));
110        }
111        if (rc != OK) {
112            ALOGE("Could not open camera %s: %d", mName.string(), rc);
113            return rc;
114        }
115        initHalPreviewWindow();
116        return rc;
117    }
118
119    /** Set the ANativeWindow to which preview frames are sent */
120    status_t setPreviewWindow(const sp<ANativeWindow>& buf)
121    {
122        ALOGV("%s(%s) buf %p", __FUNCTION__, mName.string(), buf.get());
123
124        if (mDevice->ops->set_preview_window) {
125            mPreviewWindow = buf;
126            mHalPreviewWindow.user = this;
127            ALOGV("%s &mHalPreviewWindow %p mHalPreviewWindow.user %p", __FUNCTION__,
128                    &mHalPreviewWindow, mHalPreviewWindow.user);
129            return mDevice->ops->set_preview_window(mDevice,
130                    buf.get() ? &mHalPreviewWindow.nw : 0);
131        }
132        return INVALID_OPERATION;
133    }
134
135    /** Set the notification and data callbacks */
136    void setCallbacks(notify_callback notify_cb,
137                      data_callback data_cb,
138                      data_callback_timestamp data_cb_timestamp,
139                      void* user)
140    {
141        mNotifyCb = notify_cb;
142        mDataCb = data_cb;
143        mDataCbTimestamp = data_cb_timestamp;
144        mCbUser = user;
145
146        ALOGV("%s(%s)", __FUNCTION__, mName.string());
147
148        if (mDevice->ops->set_callbacks) {
149            mDevice->ops->set_callbacks(mDevice,
150                                   __notify_cb,
151                                   __data_cb,
152                                   __data_cb_timestamp,
153                                   __get_memory,
154                                   this);
155        }
156    }
157
158    /**
159     * The following three functions all take a msgtype,
160     * which is a bitmask of the messages defined in
161     * include/ui/Camera.h
162     */
163
164    /**
165     * Enable a message, or set of messages.
166     */
167    void enableMsgType(int32_t msgType)
168    {
169        ALOGV("%s(%s)", __FUNCTION__, mName.string());
170        if (mDevice->ops->enable_msg_type)
171            mDevice->ops->enable_msg_type(mDevice, msgType);
172    }
173
174    /**
175     * Disable a message, or a set of messages.
176     *
177     * Once received a call to disableMsgType(CAMERA_MSG_VIDEO_FRAME), camera hal
178     * should not rely on its client to call releaseRecordingFrame() to release
179     * video recording frames sent out by the cameral hal before and after the
180     * disableMsgType(CAMERA_MSG_VIDEO_FRAME) call. Camera hal clients must not
181     * modify/access any video recording frame after calling
182     * disableMsgType(CAMERA_MSG_VIDEO_FRAME).
183     */
184    void disableMsgType(int32_t msgType)
185    {
186        ALOGV("%s(%s)", __FUNCTION__, mName.string());
187        if (mDevice->ops->disable_msg_type)
188            mDevice->ops->disable_msg_type(mDevice, msgType);
189    }
190
191    /**
192     * Query whether a message, or a set of messages, is enabled.
193     * Note that this is operates as an AND, if any of the messages
194     * queried are off, this will return false.
195     */
196    int msgTypeEnabled(int32_t msgType)
197    {
198        ALOGV("%s(%s)", __FUNCTION__, mName.string());
199        if (mDevice->ops->msg_type_enabled)
200            return mDevice->ops->msg_type_enabled(mDevice, msgType);
201        return false;
202    }
203
204    /**
205     * Start preview mode.
206     */
207    status_t startPreview()
208    {
209        ALOGV("%s(%s)", __FUNCTION__, mName.string());
210        if (mDevice->ops->start_preview)
211            return mDevice->ops->start_preview(mDevice);
212        return INVALID_OPERATION;
213    }
214
215    /**
216     * Stop a previously started preview.
217     */
218    void stopPreview()
219    {
220        ALOGV("%s(%s)", __FUNCTION__, mName.string());
221        if (mDevice->ops->stop_preview)
222            mDevice->ops->stop_preview(mDevice);
223    }
224
225    /**
226     * Returns true if preview is enabled.
227     */
228    int previewEnabled()
229    {
230        ALOGV("%s(%s)", __FUNCTION__, mName.string());
231        if (mDevice->ops->preview_enabled)
232            return mDevice->ops->preview_enabled(mDevice);
233        return false;
234    }
235
236    /**
237     * Request the camera hal to store meta data or real YUV data in
238     * the video buffers send out via CAMERA_MSG_VIDEO_FRRAME for a
239     * recording session. If it is not called, the default camera
240     * hal behavior is to store real YUV data in the video buffers.
241     *
242     * This method should be called before startRecording() in order
243     * to be effective.
244     *
245     * If meta data is stored in the video buffers, it is up to the
246     * receiver of the video buffers to interpret the contents and
247     * to find the actual frame data with the help of the meta data
248     * in the buffer. How this is done is outside of the scope of
249     * this method.
250     *
251     * Some camera hal may not support storing meta data in the video
252     * buffers, but all camera hal should support storing real YUV data
253     * in the video buffers. If the camera hal does not support storing
254     * the meta data in the video buffers when it is requested to do
255     * do, INVALID_OPERATION must be returned. It is very useful for
256     * the camera hal to pass meta data rather than the actual frame
257     * data directly to the video encoder, since the amount of the
258     * uncompressed frame data can be very large if video size is large.
259     *
260     * @param enable if true to instruct the camera hal to store
261     *      meta data in the video buffers; false to instruct
262     *      the camera hal to store real YUV data in the video
263     *      buffers.
264     *
265     * @return OK on success.
266     */
267
268    status_t storeMetaDataInBuffers(int enable)
269    {
270        ALOGV("%s(%s)", __FUNCTION__, mName.string());
271        if (mDevice->ops->store_meta_data_in_buffers)
272            return mDevice->ops->store_meta_data_in_buffers(mDevice, enable);
273        return enable ? INVALID_OPERATION: OK;
274    }
275
276    /**
277     * Start record mode. When a record image is available a CAMERA_MSG_VIDEO_FRAME
278     * message is sent with the corresponding frame. Every record frame must be released
279     * by a cameral hal client via releaseRecordingFrame() before the client calls
280     * disableMsgType(CAMERA_MSG_VIDEO_FRAME). After the client calls
281     * disableMsgType(CAMERA_MSG_VIDEO_FRAME), it is camera hal's responsibility
282     * to manage the life-cycle of the video recording frames, and the client must
283     * not modify/access any video recording frames.
284     */
285    status_t startRecording()
286    {
287        ALOGV("%s(%s)", __FUNCTION__, mName.string());
288        if (mDevice->ops->start_recording)
289            return mDevice->ops->start_recording(mDevice);
290        return INVALID_OPERATION;
291    }
292
293    /**
294     * Stop a previously started recording.
295     */
296    void stopRecording()
297    {
298        ALOGV("%s(%s)", __FUNCTION__, mName.string());
299        if (mDevice->ops->stop_recording)
300            mDevice->ops->stop_recording(mDevice);
301    }
302
303    /**
304     * Returns true if recording is enabled.
305     */
306    int recordingEnabled()
307    {
308        ALOGV("%s(%s)", __FUNCTION__, mName.string());
309        if (mDevice->ops->recording_enabled)
310            return mDevice->ops->recording_enabled(mDevice);
311        return false;
312    }
313
314    /**
315     * Release a record frame previously returned by CAMERA_MSG_VIDEO_FRAME.
316     *
317     * It is camera hal client's responsibility to release video recording
318     * frames sent out by the camera hal before the camera hal receives
319     * a call to disableMsgType(CAMERA_MSG_VIDEO_FRAME). After it receives
320     * the call to disableMsgType(CAMERA_MSG_VIDEO_FRAME), it is camera hal's
321     * responsibility of managing the life-cycle of the video recording
322     * frames.
323     */
324    void releaseRecordingFrame(const sp<IMemory>& mem)
325    {
326        ALOGV("%s(%s)", __FUNCTION__, mName.string());
327        if (mDevice->ops->release_recording_frame) {
328            ssize_t offset;
329            size_t size;
330            sp<IMemoryHeap> heap = mem->getMemory(&offset, &size);
331            void *data = ((uint8_t *)heap->base()) + offset;
332            return mDevice->ops->release_recording_frame(mDevice, data);
333        }
334    }
335
336    /**
337     * Start auto focus, the notification callback routine is called
338     * with CAMERA_MSG_FOCUS once when focusing is complete. autoFocus()
339     * will be called again if another auto focus is needed.
340     */
341    status_t autoFocus()
342    {
343        ALOGV("%s(%s)", __FUNCTION__, mName.string());
344        if (mDevice->ops->auto_focus)
345            return mDevice->ops->auto_focus(mDevice);
346        return INVALID_OPERATION;
347    }
348
349    /**
350     * Cancels auto-focus function. If the auto-focus is still in progress,
351     * this function will cancel it. Whether the auto-focus is in progress
352     * or not, this function will return the focus position to the default.
353     * If the camera does not support auto-focus, this is a no-op.
354     */
355    status_t cancelAutoFocus()
356    {
357        ALOGV("%s(%s)", __FUNCTION__, mName.string());
358        if (mDevice->ops->cancel_auto_focus)
359            return mDevice->ops->cancel_auto_focus(mDevice);
360        return INVALID_OPERATION;
361    }
362
363    /**
364     * Take a picture.
365     */
366    status_t takePicture()
367    {
368        ALOGV("%s(%s)", __FUNCTION__, mName.string());
369        if (mDevice->ops->take_picture)
370            return mDevice->ops->take_picture(mDevice);
371        return INVALID_OPERATION;
372    }
373
374    /**
375     * Cancel a picture that was started with takePicture.  Calling this
376     * method when no picture is being taken is a no-op.
377     */
378    status_t cancelPicture()
379    {
380        ALOGV("%s(%s)", __FUNCTION__, mName.string());
381        if (mDevice->ops->cancel_picture)
382            return mDevice->ops->cancel_picture(mDevice);
383        return INVALID_OPERATION;
384    }
385
386    /**
387     * Set the camera parameters. This returns BAD_VALUE if any parameter is
388     * invalid or not supported. */
389    status_t setParameters(const CameraParameters &params)
390    {
391        ALOGV("%s(%s)", __FUNCTION__, mName.string());
392        if (mDevice->ops->set_parameters)
393            return mDevice->ops->set_parameters(mDevice,
394                                               params.flatten().string());
395        return INVALID_OPERATION;
396    }
397
398    /** Return the camera parameters. */
399    CameraParameters getParameters() const
400    {
401        ALOGV("%s(%s)", __FUNCTION__, mName.string());
402        CameraParameters parms;
403        if (mDevice->ops->get_parameters) {
404            char *temp = mDevice->ops->get_parameters(mDevice);
405            String8 str_parms(temp);
406            if (mDevice->ops->put_parameters)
407                mDevice->ops->put_parameters(mDevice, temp);
408            else
409                free(temp);
410            parms.unflatten(str_parms);
411        }
412        return parms;
413    }
414
415    /**
416     * Send command to camera driver.
417     */
418    status_t sendCommand(int32_t cmd, int32_t arg1, int32_t arg2)
419    {
420        ALOGV("%s(%s)", __FUNCTION__, mName.string());
421        if (mDevice->ops->send_command)
422            return mDevice->ops->send_command(mDevice, cmd, arg1, arg2);
423        return INVALID_OPERATION;
424    }
425
426    /**
427     * Release the hardware resources owned by this object.  Note that this is
428     * *not* done in the destructor.
429     */
430    void release() {
431        ALOGV("%s(%s)", __FUNCTION__, mName.string());
432        if (mDevice->ops->release)
433            mDevice->ops->release(mDevice);
434    }
435
436    /**
437     * Dump state of the camera hardware
438     */
439    status_t dump(int fd, const Vector<String16>& /*args*/) const
440    {
441        ALOGV("%s(%s)", __FUNCTION__, mName.string());
442        if (mDevice->ops->dump)
443            return mDevice->ops->dump(mDevice, fd);
444        return OK; // It's fine if the HAL doesn't implement dump()
445    }
446
447private:
448    camera_device_t *mDevice;
449    String8 mName;
450
451    static void __notify_cb(int32_t msg_type, int32_t ext1,
452                            int32_t ext2, void *user)
453    {
454        ALOGV("%s", __FUNCTION__);
455        CameraHardwareInterface *__this =
456                static_cast<CameraHardwareInterface *>(user);
457        __this->mNotifyCb(msg_type, ext1, ext2, __this->mCbUser);
458    }
459
460    static void __data_cb(int32_t msg_type,
461                          const camera_memory_t *data, unsigned int index,
462                          camera_frame_metadata_t *metadata,
463                          void *user)
464    {
465        ALOGV("%s", __FUNCTION__);
466        CameraHardwareInterface *__this =
467                static_cast<CameraHardwareInterface *>(user);
468        sp<CameraHeapMemory> mem(static_cast<CameraHeapMemory *>(data->handle));
469        if (index >= mem->mNumBufs) {
470            ALOGE("%s: invalid buffer index %d, max allowed is %d", __FUNCTION__,
471                 index, mem->mNumBufs);
472            return;
473        }
474        __this->mDataCb(msg_type, mem->mBuffers[index], metadata, __this->mCbUser);
475    }
476
477    static void __data_cb_timestamp(nsecs_t timestamp, int32_t msg_type,
478                             const camera_memory_t *data, unsigned index,
479                             void *user)
480    {
481        ALOGV("%s", __FUNCTION__);
482        CameraHardwareInterface *__this =
483                static_cast<CameraHardwareInterface *>(user);
484        // Start refcounting the heap object from here on.  When the clients
485        // drop all references, it will be destroyed (as well as the enclosed
486        // MemoryHeapBase.
487        sp<CameraHeapMemory> mem(static_cast<CameraHeapMemory *>(data->handle));
488        if (index >= mem->mNumBufs) {
489            ALOGE("%s: invalid buffer index %d, max allowed is %d", __FUNCTION__,
490                 index, mem->mNumBufs);
491            return;
492        }
493        __this->mDataCbTimestamp(timestamp, msg_type, mem->mBuffers[index], __this->mCbUser);
494    }
495
496    // This is a utility class that combines a MemoryHeapBase and a MemoryBase
497    // in one.  Since we tend to use them in a one-to-one relationship, this is
498    // handy.
499
500    class CameraHeapMemory : public RefBase {
501    public:
502        CameraHeapMemory(int fd, size_t buf_size, uint_t num_buffers = 1) :
503                         mBufSize(buf_size),
504                         mNumBufs(num_buffers)
505        {
506            mHeap = new MemoryHeapBase(fd, buf_size * num_buffers);
507            commonInitialization();
508        }
509
510        CameraHeapMemory(size_t buf_size, uint_t num_buffers = 1) :
511                         mBufSize(buf_size),
512                         mNumBufs(num_buffers)
513        {
514            mHeap = new MemoryHeapBase(buf_size * num_buffers);
515            commonInitialization();
516        }
517
518        void commonInitialization()
519        {
520            handle.data = mHeap->base();
521            handle.size = mBufSize * mNumBufs;
522            handle.handle = this;
523
524            mBuffers = new sp<MemoryBase>[mNumBufs];
525            for (uint_t i = 0; i < mNumBufs; i++)
526                mBuffers[i] = new MemoryBase(mHeap,
527                                             i * mBufSize,
528                                             mBufSize);
529
530            handle.release = __put_memory;
531        }
532
533        virtual ~CameraHeapMemory()
534        {
535            delete [] mBuffers;
536        }
537
538        size_t mBufSize;
539        uint_t mNumBufs;
540        sp<MemoryHeapBase> mHeap;
541        sp<MemoryBase> *mBuffers;
542
543        camera_memory_t handle;
544    };
545
546    static camera_memory_t* __get_memory(int fd, size_t buf_size, uint_t num_bufs,
547                                         void *user __attribute__((unused)))
548    {
549        CameraHeapMemory *mem;
550        if (fd < 0)
551            mem = new CameraHeapMemory(buf_size, num_bufs);
552        else
553            mem = new CameraHeapMemory(fd, buf_size, num_bufs);
554        mem->incStrong(mem);
555        return &mem->handle;
556    }
557
558    static void __put_memory(camera_memory_t *data)
559    {
560        if (!data)
561            return;
562
563        CameraHeapMemory *mem = static_cast<CameraHeapMemory *>(data->handle);
564        mem->decStrong(mem);
565    }
566
567    static ANativeWindow *__to_anw(void *user)
568    {
569        CameraHardwareInterface *__this =
570                reinterpret_cast<CameraHardwareInterface *>(user);
571        return __this->mPreviewWindow.get();
572    }
573#define anw(n) __to_anw(((struct camera_preview_window *)n)->user)
574
575    static int __dequeue_buffer(struct preview_stream_ops* w,
576                                buffer_handle_t** buffer, int *stride)
577    {
578        int rc;
579        ANativeWindow *a = anw(w);
580        ANativeWindowBuffer* anb;
581        rc = native_window_dequeue_buffer_and_wait(a, &anb);
582        if (!rc) {
583            *buffer = &anb->handle;
584            *stride = anb->stride;
585        }
586        return rc;
587    }
588
589#ifndef container_of
590#define container_of(ptr, type, member) ({                      \
591        const typeof(((type *) 0)->member) *__mptr = (ptr);     \
592        (type *) ((char *) __mptr - (char *)(&((type *)0)->member)); })
593#endif
594
595    static int __lock_buffer(struct preview_stream_ops* w,
596                      buffer_handle_t* /*buffer*/)
597    {
598        ANativeWindow *a = anw(w);
599        (void)a;
600        return 0;
601    }
602
603    static int __enqueue_buffer(struct preview_stream_ops* w,
604                      buffer_handle_t* buffer)
605    {
606        ANativeWindow *a = anw(w);
607        return a->queueBuffer(a,
608                  container_of(buffer, ANativeWindowBuffer, handle), -1);
609    }
610
611    static int __cancel_buffer(struct preview_stream_ops* w,
612                      buffer_handle_t* buffer)
613    {
614        ANativeWindow *a = anw(w);
615        return a->cancelBuffer(a,
616                  container_of(buffer, ANativeWindowBuffer, handle), -1);
617    }
618
619    static int __set_buffer_count(struct preview_stream_ops* w, int count)
620    {
621        ANativeWindow *a = anw(w);
622        return native_window_set_buffer_count(a, count);
623    }
624
625    static int __set_buffers_geometry(struct preview_stream_ops* w,
626                      int width, int height, int format)
627    {
628        int rc;
629        ANativeWindow *a = anw(w);
630
631        rc = native_window_set_buffers_dimensions(a, width, height);
632        if (!rc) {
633            rc = native_window_set_buffers_format(a, format);
634        }
635        return rc;
636    }
637
638    static int __set_crop(struct preview_stream_ops *w,
639                      int left, int top, int right, int bottom)
640    {
641        ANativeWindow *a = anw(w);
642        android_native_rect_t crop;
643        crop.left = left;
644        crop.top = top;
645        crop.right = right;
646        crop.bottom = bottom;
647        return native_window_set_crop(a, &crop);
648    }
649
650    static int __set_timestamp(struct preview_stream_ops *w,
651                               int64_t timestamp) {
652        ANativeWindow *a = anw(w);
653        return native_window_set_buffers_timestamp(a, timestamp);
654    }
655
656    static int __set_usage(struct preview_stream_ops* w, int usage)
657    {
658        ANativeWindow *a = anw(w);
659        return native_window_set_usage(a, usage);
660    }
661
662    static int __set_swap_interval(struct preview_stream_ops *w, int interval)
663    {
664        ANativeWindow *a = anw(w);
665        return a->setSwapInterval(a, interval);
666    }
667
668    static int __get_min_undequeued_buffer_count(
669                      const struct preview_stream_ops *w,
670                      int *count)
671    {
672        ANativeWindow *a = anw(w);
673        return a->query(a, NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS, count);
674    }
675
676    void initHalPreviewWindow()
677    {
678        mHalPreviewWindow.nw.cancel_buffer = __cancel_buffer;
679        mHalPreviewWindow.nw.lock_buffer = __lock_buffer;
680        mHalPreviewWindow.nw.dequeue_buffer = __dequeue_buffer;
681        mHalPreviewWindow.nw.enqueue_buffer = __enqueue_buffer;
682        mHalPreviewWindow.nw.set_buffer_count = __set_buffer_count;
683        mHalPreviewWindow.nw.set_buffers_geometry = __set_buffers_geometry;
684        mHalPreviewWindow.nw.set_crop = __set_crop;
685        mHalPreviewWindow.nw.set_timestamp = __set_timestamp;
686        mHalPreviewWindow.nw.set_usage = __set_usage;
687        mHalPreviewWindow.nw.set_swap_interval = __set_swap_interval;
688
689        mHalPreviewWindow.nw.get_min_undequeued_buffer_count =
690                __get_min_undequeued_buffer_count;
691    }
692
693    sp<ANativeWindow>        mPreviewWindow;
694
695    struct camera_preview_window {
696        struct preview_stream_ops nw;
697        void *user;
698    };
699
700    struct camera_preview_window mHalPreviewWindow;
701
702    notify_callback         mNotifyCb;
703    data_callback           mDataCb;
704    data_callback_timestamp mDataCbTimestamp;
705    void *mCbUser;
706};
707
708};  // namespace android
709
710#endif
711