hc
2023-11-22 f743a7adbd6e230d66a6206fa115b59fec2d88eb
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
/*
 * poll_thread.cpp - poll thread for event and buffer
 *
 *  Copyright (c) 2014-2015 Intel Corporation
 *
 * 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.
 *
 * Author: Wind Yuan <feng.yuan@intel.com>
 */
 
#include "poll_thread.h"
#include "xcam_thread.h"
//#include <linux/rkisp.h>
#include <unistd.h>
#include <fcntl.h>
 
namespace XCam {
 
class PollThread;
 
const char*
PollThread::isp_poll_type_to_str[ISP_POLL_POST_MAX] =
{
    "luma_poll",
    "ispp_poll",
    "stats_poll",
    "params_poll",
    "pparams_poll",
};
 
class IspPollThread
    : public Thread
{
public:
    IspPollThread (PollThread *poll, int type)
        : Thread (PollThread::isp_poll_type_to_str[type])
        , _poll (poll)
        , _type (type)
    {}
 
protected:
    virtual bool loop () {
        XCamReturn ret = _poll->poll_buffer_loop (_type);
 
        if (ret == XCAM_RETURN_NO_ERROR || ret == XCAM_RETURN_ERROR_TIMEOUT ||
                XCAM_RETURN_BYPASS)
            return true;
        return false;
    }
 
private:
    PollThread   *_poll;
    int _type;
};
 
class EventPollThread
    : public Thread
{
public:
    EventPollThread (PollThread *poll)
        : Thread ("event_poll")
        , _poll (poll)
    {}
 
protected:
    virtual bool loop () {
        XCamReturn ret = _poll->poll_subdev_event_loop ();
 
        if (ret == XCAM_RETURN_NO_ERROR || ret == XCAM_RETURN_ERROR_TIMEOUT)
            return true;
        return false;
    }
 
private:
    PollThread   *_poll;
};
 
const int PollThread::default_poll_timeout = 300; // ms
 
PollThread::PollThread ()
    : _poll_callback (NULL)
    , frameid (0)
{
#if 0
    SmartPtr<EventPollThread> event_loop = new EventPollThread(this);
    XCAM_ASSERT (event_loop.ptr ());
    _event_loop = event_loop;
 
    SmartPtr<IspPollThread> isp_stats_loop = new IspPollThread(this, ISP_POLL_3A_STATS);
    XCAM_ASSERT (isp_stats_loop.ptr ());
    _isp_stats_loop = isp_stats_loop;
 
    SmartPtr<IspPollThread> isp_luma_loop = new IspPollThread(this, ISP_POLL_LUMA);
    XCAM_ASSERT (isp_luma_loop.ptr ());
    _isp_luma_loop = isp_luma_loop;
 
    SmartPtr<IspPollThread> isp_params_loop = new IspPollThread(this, ISP_POLL_PARAMS);
    XCAM_ASSERT (isp_params_loop.ptr ());
    _isp_params_loop = isp_params_loop;
 
    SmartPtr<IspPollThread> isp_pparams_loop = new IspPollThread(this, ISP_POLL_POST_PARAMS);
    XCAM_ASSERT (isp_pparams_loop.ptr ());
    _isp_pparams_loop = isp_pparams_loop;
 
    SmartPtr<IspPollThread> ispp_stats_loop = new IspPollThread(this, ISPP_POLL_STATS);
    XCAM_ASSERT (ispp_stats_loop.ptr ());
    _ispp_stats_loop = ispp_stats_loop;
 
    _ispp_poll_stop_fd[0] =  -1;
    _ispp_poll_stop_fd[1] =  -1;
    _luma_poll_stop_fd[0] =  -1;
    _luma_poll_stop_fd[1] =  -1;
    _3a_stats_poll_stop_fd[0] =  -1;
    _3a_stats_poll_stop_fd[1] =  -1;
    _event_poll_stop_fd[0] = -1;
    _event_poll_stop_fd[1] = -1;
    _isp_params_poll_stop_fd[0] = -1;
    _isp_params_poll_stop_fd[1] = -1;
    _isp_pparams_poll_stop_fd[0] = -1;
    _isp_pparams_poll_stop_fd[1] = -1;
#endif
    XCAM_LOG_DEBUG ("PollThread constructed");
}
 
PollThread::~PollThread ()
{
    stop();
 
    XCAM_LOG_DEBUG ("~PollThread destructed");
}
 
bool
PollThread::set_event_device (SmartPtr<V4l2SubDevice> &dev)
{
    XCAM_ASSERT (!_event_dev.ptr());
    _event_dev = dev;
    return true;
}
 
bool
PollThread::set_isp_stats_device (SmartPtr<V4l2Device> &dev)
{
    XCAM_ASSERT (!_isp_stats_dev.ptr());
    _isp_stats_dev = dev;
    return true;
}
 
bool
PollThread::set_isp_luma_device (SmartPtr<V4l2Device> &dev)
{
    XCAM_ASSERT (!_isp_luma_dev.ptr());
    _isp_luma_dev = dev;
    return true;
}
 
bool
PollThread::set_ispp_stats_device (SmartPtr<V4l2Device> &dev)
{
    XCAM_ASSERT (!_ispp_stats_dev.ptr());
    _ispp_stats_dev = dev;
    return true;
}
 
bool
PollThread::set_isp_params_devices (SmartPtr<V4l2Device> &params_dev,
                                    SmartPtr<V4l2Device> &post_params_dev)
{
    XCAM_ASSERT (!_isp_params_dev.ptr());
    XCAM_ASSERT (!_isp_pparams_dev.ptr());
    _isp_params_dev = params_dev;
    _isp_pparams_dev = post_params_dev;
    return true;
}
 
bool
PollThread::set_poll_callback (PollCallback *callback)
{
    XCAM_ASSERT (!_poll_callback);
    _poll_callback = callback;
    return true;
}
 
void PollThread::destroy_stop_fds () {
    if (_ispp_poll_stop_fd[1] != -1 || _ispp_poll_stop_fd[0] != -1) {
        close(_ispp_poll_stop_fd[0]);
        close(_ispp_poll_stop_fd[1]);
        _ispp_poll_stop_fd[0] = -1;
        _ispp_poll_stop_fd[1] = -1;
    }
 
    if (_luma_poll_stop_fd[1] != -1 || _luma_poll_stop_fd[0] != -1) {
        close(_luma_poll_stop_fd[0]);
        close(_luma_poll_stop_fd[1]);
        _luma_poll_stop_fd[0] = -1;
        _luma_poll_stop_fd[1] = -1;
    }
 
    if (_3a_stats_poll_stop_fd[1] != -1 || _3a_stats_poll_stop_fd[0] != -1) {
        close(_3a_stats_poll_stop_fd[0]);
        close(_3a_stats_poll_stop_fd[1]);
        _3a_stats_poll_stop_fd[0] = -1;
        _3a_stats_poll_stop_fd[1] = -1;
    }
 
    if (_event_poll_stop_fd[1] != -1 || _event_poll_stop_fd[0] != -1) {
        close(_event_poll_stop_fd[0]);
        close(_event_poll_stop_fd[1]);
        _event_poll_stop_fd[0] = -1;
        _event_poll_stop_fd[1] = -1;
    }
 
    if (_isp_params_poll_stop_fd[1] != -1 || _isp_params_poll_stop_fd[0] != -1) {
        close(_isp_params_poll_stop_fd[0]);
        close(_isp_params_poll_stop_fd[1]);
        _isp_params_poll_stop_fd[0] = -1;
        _isp_params_poll_stop_fd[1] = -1;
    }
 
    if (_isp_pparams_poll_stop_fd[1] != -1 || _isp_pparams_poll_stop_fd[0] != -1) {
        close(_isp_pparams_poll_stop_fd[0]);
        close(_isp_pparams_poll_stop_fd[1]);
        _isp_pparams_poll_stop_fd[0] = -1;
        _isp_pparams_poll_stop_fd[1] = -1;
    }
}
 
XCamReturn PollThread::create_stop_fds () {
    int status = 0;
    XCamReturn ret = XCAM_RETURN_NO_ERROR;
 
    destroy_stop_fds ();
 
    status = pipe(_ispp_poll_stop_fd);
    if (status < 0) {
        XCAM_LOG_ERROR ("Failed to create ispp poll stop pipe: %s", strerror(errno));
        ret = XCAM_RETURN_ERROR_UNKNOWN;
        goto exit_error;
    }
 
    /**
     * make the reading end of the pipe non blocking.
     * This helps during flush to read any information left there without
     * blocking
     */
    status = fcntl(_ispp_poll_stop_fd[0], F_SETFL, O_NONBLOCK);
    if (status < 0) {
        XCAM_LOG_ERROR ("Fail to set event ispp stop pipe flag: %s", strerror(errno));
        ret = XCAM_RETURN_ERROR_UNKNOWN;
        goto exit_error;
    }
 
    status = pipe(_luma_poll_stop_fd);
    if (status < 0) {
        XCAM_LOG_ERROR ("Failed to create luma poll stop pipe: %s", strerror(errno));
        ret = XCAM_RETURN_ERROR_UNKNOWN;
        goto exit_error;
    }
 
    /**
     * make the reading end of the pipe non blocking.
     * This helps during flush to read any information left there without
     * blocking
     */
    status = fcntl(_luma_poll_stop_fd[0], F_SETFL, O_NONBLOCK);
    if (status < 0) {
        XCAM_LOG_ERROR ("Fail to set event luma stop pipe flag: %s", strerror(errno));
        ret = XCAM_RETURN_ERROR_UNKNOWN;
        goto exit_error;
    }
 
    status = pipe(_3a_stats_poll_stop_fd);
    if (status < 0) {
        XCAM_LOG_ERROR ("Failed to create stats poll stop pipe: %s", strerror(errno));
        ret = XCAM_RETURN_ERROR_UNKNOWN;
        goto exit_error;
    }
 
    /**
     * make the reading end of the pipe non blocking.
     * This helps during flush to read any information left there without
     * blocking
     */
    status = fcntl(_3a_stats_poll_stop_fd[0], F_SETFL, O_NONBLOCK);
    if (status < 0) {
        XCAM_LOG_ERROR ("Fail to set stats poll stop pipe flag: %s", strerror(errno));
        ret = XCAM_RETURN_ERROR_UNKNOWN;
        goto exit_error;
    }
 
    status = pipe(_event_poll_stop_fd);
    if (status < 0) {
        XCAM_LOG_ERROR ("Failed to create event poll stop pipe: %s", strerror(errno));
        ret = XCAM_RETURN_ERROR_UNKNOWN;
        goto exit_error;
    }
 
    /**
     * make the reading end of the pipe non blocking.
     * This helps during flush to read any information left there without
     * blocking
     */
    status = fcntl(_event_poll_stop_fd[0], F_SETFL, O_NONBLOCK);
    if (status < 0) {
        XCAM_LOG_ERROR ("Fail to set stats poll stop pipe flag: %s", strerror(errno));
        ret = XCAM_RETURN_ERROR_UNKNOWN;
        goto exit_error;
    }
 
    status = pipe(_isp_params_poll_stop_fd);
    if (status < 0) {
        XCAM_LOG_ERROR ("Failed to create params poll stop pipe: %s", strerror(errno));
        ret = XCAM_RETURN_ERROR_UNKNOWN;
        goto exit_error;
    }
 
    /**
     * make the reading end of the pipe non blocking.
     * This helps during flush to read any information left there without
     * blocking
     */
    status = fcntl(_isp_params_poll_stop_fd[0], F_SETFL, O_NONBLOCK);
    if (status < 0) {
        XCAM_LOG_ERROR ("Fail to set params poll stop pipe flag: %s", strerror(errno));
        ret = XCAM_RETURN_ERROR_UNKNOWN;
        goto exit_error;
    }
 
    status = pipe(_isp_pparams_poll_stop_fd);
    if (status < 0) {
        XCAM_LOG_ERROR ("Failed to create pparams poll stop pipe: %s", strerror(errno));
        ret = XCAM_RETURN_ERROR_UNKNOWN;
        goto exit_error;
    }
 
    /**
     * make the reading end of the pipe non blocking.
     * This helps during flush to read any information left there without
     * blocking
     */
    status = fcntl(_isp_pparams_poll_stop_fd[0], F_SETFL, O_NONBLOCK);
    if (status < 0) {
        XCAM_LOG_ERROR ("Fail to set pparams poll stop pipe flag: %s", strerror(errno));
        ret = XCAM_RETURN_ERROR_UNKNOWN;
        goto exit_error;
    }
    return XCAM_RETURN_NO_ERROR;
exit_error:
    destroy_stop_fds ();
    return ret;
}
 
XCamReturn PollThread::start ()
{
    if (create_stop_fds ()) {
        XCAM_LOG_ERROR("create stop fds failed !");
        return XCAM_RETURN_ERROR_UNKNOWN;
    }
 
    if (_event_dev.ptr () && !_event_loop->start ()) {
        return XCAM_RETURN_ERROR_THREAD;
    }
 
    if (_isp_stats_dev.ptr () && !_isp_stats_loop->start ()) {
        return XCAM_RETURN_ERROR_THREAD;
    }
 
    if (_isp_luma_dev.ptr () && !_isp_luma_loop->start ()) {
        return XCAM_RETURN_ERROR_THREAD;
    }
 
    if (_isp_params_dev.ptr () && !_isp_params_loop->start ()) {
        return XCAM_RETURN_ERROR_THREAD;
    }
 
    if (_ispp_stats_dev.ptr () && !_ispp_stats_loop->start ()) {
        return XCAM_RETURN_ERROR_THREAD;
    }
 
    if (_isp_pparams_dev.ptr () && !_isp_pparams_loop->start ()) {
        return XCAM_RETURN_ERROR_THREAD;
    }
 
    return XCAM_RETURN_NO_ERROR;
}
 
XCamReturn PollThread::stop ()
{
    XCAM_LOG_DEBUG ("PollThread stop");
 
    if (_event_dev.ptr ()) {
        if (_event_poll_stop_fd[1] != -1) {
            char buf = 0xf;  // random value to write to flush fd.
            unsigned int size = write(_event_poll_stop_fd[1], &buf, sizeof(char));
            if (size != sizeof(char))
                XCAM_LOG_WARNING("Flush write not completed");
        }
        _event_loop->stop ();
    }
 
    if (_ispp_stats_dev.ptr ()) {
        if (_ispp_poll_stop_fd[1] != -1) {
            char buf = 0xf;  // random value to write to flush fd.
            unsigned int size = write(_ispp_poll_stop_fd[1], &buf, sizeof(char));
            if (size != sizeof(char))
                XCAM_LOG_WARNING("Flush write not completed");
        }
        _ispp_stats_loop->stop ();
    }
 
    if (_isp_stats_dev.ptr ()) {
        if (_3a_stats_poll_stop_fd[1] != -1) {
            char buf = 0xf;  // random value to write to flush fd.
            unsigned int size = write(_3a_stats_poll_stop_fd[1], &buf, sizeof(char));
            if (size != sizeof(char))
                XCAM_LOG_WARNING("Flush write not completed");
        }
        _isp_stats_loop->stop ();
    }
 
    if (_isp_luma_dev.ptr ()) {
        if (_luma_poll_stop_fd[1] != -1) {
            char buf = 0xf;  // random value to write to flush fd.
            unsigned int size = write(_luma_poll_stop_fd[1], &buf, sizeof(char));
            if (size != sizeof(char))
                XCAM_LOG_WARNING("Flush write not completed");
        }
        _isp_luma_loop->stop ();
    }
 
    if (_isp_params_dev.ptr ()) {
        if (_isp_params_poll_stop_fd[1] != -1) {
            char buf = 0xf;  // random value to write to flush fd.
            unsigned int size = write(_isp_params_poll_stop_fd[1], &buf, sizeof(char));
            if (size != sizeof(char))
                XCAM_LOG_WARNING("Flush write not completed");
        }
        _isp_params_loop->stop ();
    }
 
    if (_isp_pparams_dev.ptr ()) {
        if (_isp_pparams_poll_stop_fd[1] != -1) {
            char buf = 0xf;  // random value to write to flush fd.
            unsigned int size = write(_isp_pparams_poll_stop_fd[1], &buf, sizeof(char));
            if (size != sizeof(char))
                XCAM_LOG_WARNING("Flush write not completed");
        }
        _isp_pparams_loop->stop ();
    }
 
    destroy_stop_fds ();
 
    return XCAM_RETURN_NO_ERROR;
}
 
XCamReturn
PollThread::notify_sof (uint64_t time, int frameid)
{
    XCAM_UNUSED (time);
    XCAM_UNUSED (frameid);
 
    return XCAM_RETURN_NO_ERROR;
}
 
XCamReturn
PollThread::handle_events (struct v4l2_event &event)
{
    XCamReturn ret = XCAM_RETURN_NO_ERROR;
    switch (event.type) {
    case V4L2_EVENT_FRAME_SYNC:
        ret = handle_frame_sync_event (event);
        break;
    default:
        ret = XCAM_RETURN_ERROR_UNKNOWN;
        break;
    }
 
    return ret;
}
 
XCamReturn
PollThread::handle_frame_sync_event (struct v4l2_event &event)
{
    int64_t tv_sec = event.timestamp.tv_sec;
    int64_t tv_nsec = event.timestamp.tv_nsec;
    int exp_id = event.u.frame_sync.frame_sequence;
 
    notify_sof(tv_sec * 1000 * 1000 * 1000 + tv_nsec, exp_id);
 
    return XCAM_RETURN_NO_ERROR;
}
 
XCamReturn
PollThread::poll_subdev_event_loop ()
{
    XCamReturn ret = XCAM_RETURN_NO_ERROR;
    struct v4l2_event event;
    int poll_ret = 0;
 
    poll_ret = _event_dev->poll_event (PollThread::default_poll_timeout,
                                       _event_poll_stop_fd[0]);
 
    if (poll_ret == POLL_STOP_RET) {
        XCAM_LOG_DEBUG ("poll event stop success !");
        // stop success, return error to stop the poll thread
        return XCAM_RETURN_ERROR_UNKNOWN;
    }
 
    if (poll_ret < 0) {
        XCAM_LOG_WARNING ("poll event failed but continue");
        ::usleep (1000); // 1ms
        return XCAM_RETURN_ERROR_TIMEOUT;
    }
 
    /* timeout */
    if (poll_ret == 0) {
        XCAM_LOG_WARNING ("poll event timeout and continue");
        return XCAM_RETURN_ERROR_TIMEOUT;
    }
 
    xcam_mem_clear (event);
    ret = _event_dev->dequeue_event (event);
    if (ret != XCAM_RETURN_NO_ERROR) {
        XCAM_LOG_WARNING ("dequeue event failed on dev:%s", XCAM_STR(_event_dev->get_device_name()));
        return XCAM_RETURN_ERROR_IOCTL;
    }
 
    ret = handle_events (event);
 
    XCAM_ASSERT (_poll_callback);
 
    if (_poll_callback && event.type == V4L2_EVENT_FRAME_SYNC)
        return _poll_callback->poll_event_ready (event.u.frame_sync.frame_sequence,
                                                 event.type);
 
    return ret;
}
 
SmartPtr<VideoBuffer>
PollThread::new_video_buffer(SmartPtr<V4l2Buffer> buf,
                             SmartPtr<V4l2Device> dev,
                             int type)
{
    SmartPtr<VideoBuffer> video_buf = new V4l2BufferProxy (buf, dev);
 
    return video_buf;
}
 
XCamReturn
PollThread::poll_buffer_loop (int type)
{
    XCamReturn ret = XCAM_RETURN_NO_ERROR;
    int poll_ret = 0;
    SmartPtr<V4l2Buffer> buf;
    SmartPtr<V4l2Device> dev;
    int stop_fd = -1;
#if 0
    if (type == ISP_POLL_LUMA) {
        dev = _isp_luma_dev;
        stop_fd = _luma_poll_stop_fd[0];
    } else if (type == ISPP_POLL_STATS) {
        dev = _ispp_stats_dev;
        stop_fd = _ispp_poll_stop_fd[0];
    } else if (type == ISP_POLL_3A_STATS) {
        dev = _isp_stats_dev;
        stop_fd = _3a_stats_poll_stop_fd[0];
    } else if (type == ISP_POLL_PARAMS) {
        dev = _isp_params_dev;
        stop_fd = _isp_params_poll_stop_fd[0];
    } else if (type == ISP_POLL_POST_PARAMS) {
        dev = _isp_pparams_dev;
        stop_fd = _isp_pparams_poll_stop_fd[0];
    } else
        return XCAM_RETURN_ERROR_UNKNOWN;
 
    poll_ret = dev->poll_event (PollThread::default_poll_timeout,
                                stop_fd);
 
    if (poll_ret == POLL_STOP_RET) {
        XCAM_LOG_DEBUG ("poll %s buffer stop success !", isp_poll_type_to_str[type]);
        // stop success, return error to stop the poll thread
        return XCAM_RETURN_ERROR_UNKNOWN;
    }
 
    if (poll_ret <= 0) {
        XCAM_LOG_DEBUG ("poll %s buffer event got error(0x%x) but continue\n", isp_poll_type_to_str[type], poll_ret);
        ::usleep (100000); // 100ms
        return XCAM_RETURN_ERROR_TIMEOUT;
    }
 
    ret = dev->dequeue_buffer (buf);
    if (ret != XCAM_RETURN_NO_ERROR) {
        XCAM_LOG_WARNING ("dequeue %s buffer failed", isp_poll_type_to_str[type]);
        return ret;
    }
 
    XCAM_ASSERT (buf.ptr());
    XCAM_ASSERT (_poll_callback);
 
    if (_poll_callback &&
            (type == ISP_POLL_3A_STATS || type == ISP_POLL_LUMA || type == ISPP_POLL_STATS)) {
        SmartPtr<VideoBuffer> video_buf = new_video_buffer(buf, dev, type);
 
        return _poll_callback->poll_buffer_ready (video_buf, type);
    }
#endif
    return ret;
}
 
};