Exemplo n.º 1
0
/*===========================================================================
 * FUNCTION   : mm_camera_poll_proc_pipe
 *
 * DESCRIPTION: polling thread routine to process pipe
 *
 * PARAMETERS :
 *   @poll_cb : ptr to poll thread object
 *
 * RETURN     : none
 *==========================================================================*/
static void mm_camera_poll_proc_pipe(mm_camera_poll_thread_t *poll_cb)
{
    ssize_t read_len;
    int i;
    mm_camera_sig_evt_t cmd_evt;
    read_len = read(poll_cb->pfds[0], &cmd_evt, sizeof(cmd_evt));
    CDBG("%s: read_fd = %d, read_len = %d, expect_len = %d cmd = %d",
         __func__, poll_cb->pfds[0], (int)read_len, (int)sizeof(cmd_evt), cmd_evt.cmd);
    switch (cmd_evt.cmd) {
    case MM_CAMERA_PIPE_CMD_POLL_ENTRIES_UPDATED:
    case MM_CAMERA_PIPE_CMD_POLL_ENTRIES_UPDATED_ASYNC:
        /* we always have index 0 for pipe read */
        poll_cb->num_fds = 0;
        poll_cb->poll_fds[poll_cb->num_fds].fd = poll_cb->pfds[0];
        poll_cb->poll_fds[poll_cb->num_fds].events = POLLIN|POLLRDNORM|POLLPRI;
        poll_cb->num_fds++;

        if (MM_CAMERA_POLL_TYPE_EVT == poll_cb->poll_type) {
            if (poll_cb->poll_entries[0].fd > 0) {
                /* fd is valid, we update poll_fds */
                poll_cb->poll_fds[poll_cb->num_fds].fd = poll_cb->poll_entries[0].fd;
                poll_cb->poll_fds[poll_cb->num_fds].events = POLLIN|POLLRDNORM|POLLPRI;
                poll_cb->num_fds++;
            }
        } else if (MM_CAMERA_POLL_TYPE_DATA == poll_cb->poll_type) {
            for(i = 0; i < MAX_STREAM_NUM_IN_BUNDLE; i++) {
                if(poll_cb->poll_entries[i].fd > 0) {
                    /* fd is valid, we update poll_fds to this fd */
                    poll_cb->poll_fds[poll_cb->num_fds].fd = poll_cb->poll_entries[i].fd;
                    poll_cb->poll_fds[poll_cb->num_fds].events = POLLIN|POLLRDNORM|POLLPRI;
                    poll_cb->num_fds++;
                } else {
                    /* fd is invalid, we set the entry to -1 to prevent polling.
                     * According to spec, polling will not poll on entry with fd=-1.
                     * If this is not the case, we need to skip these invalid fds
                     * when updating this array.
                     * We still keep fd=-1 in this array because this makes easier to
                     * map cb associated with this fd once incoming data avail by directly
                     * using the index-1(0 is reserved for pipe read, so need to reduce index by 1) */
                    poll_cb->poll_fds[poll_cb->num_fds].fd = -1;
                    poll_cb->poll_fds[poll_cb->num_fds].events = 0;
                    poll_cb->num_fds++;
                }
            }
        }
        if (cmd_evt.cmd != MM_CAMERA_PIPE_CMD_POLL_ENTRIES_UPDATED_ASYNC)
            mm_camera_poll_sig_done(poll_cb);
        break;

    case MM_CAMERA_PIPE_CMD_EXIT:
    default:
        mm_camera_poll_set_state(poll_cb, MM_CAMERA_POLL_TASK_STATE_STOPPED);
        mm_camera_poll_sig_done(poll_cb);
        break;
    }
}
Exemplo n.º 2
0
/*===========================================================================
 * FUNCTION   : mm_camera_poll_thread
 *
 * DESCRIPTION: polling thread entry function
 *
 * PARAMETERS :
 *   @data    : ptr to poll thread object
 *
 * RETURN     : none
 *==========================================================================*/
static void *mm_camera_poll_thread(void *data)
{
    mm_camera_poll_thread_t *poll_cb = (mm_camera_poll_thread_t *)data;

    /* add pipe read fd into poll first */
    poll_cb->poll_fds[poll_cb->num_fds++].fd = poll_cb->pfds[0];

    mm_camera_poll_sig_done(poll_cb);
    mm_camera_poll_set_state(poll_cb, MM_CAMERA_POLL_TASK_STATE_POLL);
    return mm_camera_poll_fn(poll_cb);
}
Exemplo n.º 3
0
static void mm_camera_poll_proc_pipe(mm_camera_poll_thread_t *poll_cb)
{
    ssize_t read_len;
    int i;
    mm_camera_sig_evt_t cmd_evt;
    read_len = read(poll_cb->data.pfds[0], &cmd_evt, sizeof(cmd_evt));
    CDBG("%s: read_fd = %d, read_len = %d, expect_len = %d",
         __func__, poll_cb->data.pfds[0], (int)read_len, (int)sizeof(cmd_evt));
    switch(cmd_evt.cmd) {
    case MM_CAMERA_PIPE_CMD_FLASH_QUEUED_FRAME:
      mm_camera_dispatch_buffered_frames(poll_cb->data.my_obj,
                                         poll_cb->data.ch_type);
      break;
    case MM_CAMERA_PIPE_CMD_CH_EVENT: {
      mm_camera_event_t *event = &cmd_evt.event;
      CDBG("%s: ch event, type=0x%x, ch=%d, evt=%d",
           __func__, event->event_type, event->e.ch.ch, event->e.ch.evt);
      mm_camera_dispatch_app_event(poll_cb->data.my_obj, event);
      break;
    }
    case MM_CAMERA_PIPE_CMD_ADD_CH:
        if(poll_cb->data.poll_type == MM_CAMERA_POLL_TYPE_CH) {
            for(i = 0; i < MM_CAMERA_CH_STREAM_MAX; i++) {
                if(poll_cb->data.poll_streams[i]) {
                    poll_cb->data.poll_fd[poll_cb->data.num_fds + i] = poll_cb->data.poll_streams[i]->fd;
                }
            }
        }
        poll_cb->data.num_fds += mm_camera_ch_util_get_num_stream(poll_cb->data.my_obj,
                                                                      poll_cb->data.ch_type);
        poll_cb->data.used = 1;
        CDBG("Num fds after MM_CAMERA_PIPE_CMD_ADD_CH = %d",poll_cb->data.num_fds);
        break;

    case MM_CAMERA_PIPE_CMD_DEL_CH:
        poll_cb->data.num_fds -= mm_camera_ch_util_get_num_stream(poll_cb->data.my_obj,
                                                                  poll_cb->data.ch_type);
        poll_cb->data.used = 0;
        CDBG("Num fds after MM_CAMERA_PIPE_CMD_DEL_CH = %d",poll_cb->data.num_fds);
        break;

    case MM_CAMERA_PIPE_CMD_EXIT:
    default:
        cm_camera_poll_set_state(poll_cb, MM_CAMERA_POLL_TASK_STATE_MAX);
        mm_camera_poll_sig_done(poll_cb);
        break;
    }
}
Exemplo n.º 4
0
static void *mm_camera_poll_thread(void *data)
{
    int rc = 0;
    int i;
    void *ret = NULL;
    mm_camera_poll_thread_t *poll_cb = (mm_camera_poll_thread_t *)data;

    /* add pipe read fd into poll first */
    poll_cb->poll_fds[poll_cb->num_fds++].fd = poll_cb->pfds[0];

    //poll_cb->poll_fds[poll_cb->num_fds++].fd = (((mm_camera_obj_t *)poll_cb->my_obj)->ctrl_fd);

    mm_camera_poll_sig_done(poll_cb);
    mm_camera_poll_set_state(poll_cb, MM_CAMERA_POLL_TASK_STATE_POLL);
    ret = mm_camera_poll_fn(poll_cb);
    return ret;
}
Exemplo n.º 5
0
static void *mm_camera_poll_thread(void *data)
{
    int rc = 0;
    int i;
    void *ret = NULL;
    mm_camera_poll_thread_t *poll_cb = data;

    poll_cb->data.poll_fd[poll_cb->data.num_fds++] = poll_cb->data.pfds[0];
    switch(poll_cb->data.poll_type) {
    case MM_CAMERA_POLL_TYPE_EVT:
        poll_cb->data.poll_fd[poll_cb->data.num_fds++] =
          ((mm_camera_obj_t *)(poll_cb->data.my_obj))->ctrl_fd;
        break;
    case MM_CAMERA_POLL_TYPE_CH:
    default:
        break;
    }
    mm_camera_poll_sig_done(poll_cb);
    ret = mm_camera_poll_fn(poll_cb);
    return ret;
}