fim 63 drivers/staging/media/imx/imx-media-csi.c struct imx_media_fim *fim; fim 313 drivers/staging/media/imx/imx-media-csi.c if (priv->fim) fim 315 drivers/staging/media/imx/imx-media-csi.c imx_media_fim_eof_monitor(priv->fim, ktime_get()); fim 778 drivers/staging/media/imx/imx-media-csi.c if (priv->fim && priv->dest == IPU_CSI_DEST_IDMAC) { fim 779 drivers/staging/media/imx/imx-media-csi.c ret = imx_media_fim_set_stream(priv->fim, output_fi, true); fim 793 drivers/staging/media/imx/imx-media-csi.c if (priv->fim && priv->dest == IPU_CSI_DEST_IDMAC) fim 794 drivers/staging/media/imx/imx-media-csi.c imx_media_fim_set_stream(priv->fim, NULL, false); fim 822 drivers/staging/media/imx/imx-media-csi.c if (priv->fim) fim 823 drivers/staging/media/imx/imx-media-csi.c imx_media_fim_set_stream(priv->fim, NULL, false); fim 1067 drivers/staging/media/imx/imx-media-csi.c if (priv->fim) { fim 1068 drivers/staging/media/imx/imx-media-csi.c ret = imx_media_fim_add_controls(priv->fim); fim 1790 drivers/staging/media/imx/imx-media-csi.c priv->fim = imx_media_fim_init(&priv->sd); fim 1791 drivers/staging/media/imx/imx-media-csi.c if (IS_ERR(priv->fim)) { fim 1792 drivers/staging/media/imx/imx-media-csi.c ret = PTR_ERR(priv->fim); fim 1807 drivers/staging/media/imx/imx-media-csi.c if (priv->fim) fim 1808 drivers/staging/media/imx/imx-media-csi.c imx_media_fim_free(priv->fim); fim 1820 drivers/staging/media/imx/imx-media-csi.c if (priv->fim) fim 1821 drivers/staging/media/imx/imx-media-csi.c imx_media_fim_free(priv->fim); fim 71 drivers/staging/media/imx/imx-media-fim.c #define icap_enabled(fim) ((fim)->icap_flags != IRQ_TYPE_NONE) fim 73 drivers/staging/media/imx/imx-media-fim.c static void update_fim_nominal(struct imx_media_fim *fim, fim 77 drivers/staging/media/imx/imx-media-fim.c dev_dbg(fim->sd->dev, "no frame interval, FIM disabled\n"); fim 78 drivers/staging/media/imx/imx-media-fim.c fim->enabled = false; fim 82 drivers/staging/media/imx/imx-media-fim.c fim->nominal = DIV_ROUND_CLOSEST_ULL(1000000ULL * (u64)fi->numerator, fim 85 drivers/staging/media/imx/imx-media-fim.c dev_dbg(fim->sd->dev, "FI=%lu usec\n", fim->nominal); fim 88 drivers/staging/media/imx/imx-media-fim.c static void reset_fim(struct imx_media_fim *fim, bool curval) fim 90 drivers/staging/media/imx/imx-media-fim.c struct v4l2_ctrl *icap_chan = fim->icap_ctrl[FIM_CL_ICAP_CHANNEL]; fim 91 drivers/staging/media/imx/imx-media-fim.c struct v4l2_ctrl *icap_edge = fim->icap_ctrl[FIM_CL_ICAP_EDGE]; fim 92 drivers/staging/media/imx/imx-media-fim.c struct v4l2_ctrl *en = fim->ctrl[FIM_CL_ENABLE]; fim 93 drivers/staging/media/imx/imx-media-fim.c struct v4l2_ctrl *num = fim->ctrl[FIM_CL_NUM]; fim 94 drivers/staging/media/imx/imx-media-fim.c struct v4l2_ctrl *skip = fim->ctrl[FIM_CL_NUM_SKIP]; fim 95 drivers/staging/media/imx/imx-media-fim.c struct v4l2_ctrl *tol_min = fim->ctrl[FIM_CL_TOLERANCE_MIN]; fim 96 drivers/staging/media/imx/imx-media-fim.c struct v4l2_ctrl *tol_max = fim->ctrl[FIM_CL_TOLERANCE_MAX]; fim 99 drivers/staging/media/imx/imx-media-fim.c fim->enabled = en->cur.val; fim 100 drivers/staging/media/imx/imx-media-fim.c fim->icap_flags = icap_edge->cur.val; fim 101 drivers/staging/media/imx/imx-media-fim.c fim->icap_channel = icap_chan->cur.val; fim 102 drivers/staging/media/imx/imx-media-fim.c fim->num_avg = num->cur.val; fim 103 drivers/staging/media/imx/imx-media-fim.c fim->num_skip = skip->cur.val; fim 104 drivers/staging/media/imx/imx-media-fim.c fim->tolerance_min = tol_min->cur.val; fim 105 drivers/staging/media/imx/imx-media-fim.c fim->tolerance_max = tol_max->cur.val; fim 107 drivers/staging/media/imx/imx-media-fim.c fim->enabled = en->val; fim 108 drivers/staging/media/imx/imx-media-fim.c fim->icap_flags = icap_edge->val; fim 109 drivers/staging/media/imx/imx-media-fim.c fim->icap_channel = icap_chan->val; fim 110 drivers/staging/media/imx/imx-media-fim.c fim->num_avg = num->val; fim 111 drivers/staging/media/imx/imx-media-fim.c fim->num_skip = skip->val; fim 112 drivers/staging/media/imx/imx-media-fim.c fim->tolerance_min = tol_min->val; fim 113 drivers/staging/media/imx/imx-media-fim.c fim->tolerance_max = tol_max->val; fim 117 drivers/staging/media/imx/imx-media-fim.c if (fim->tolerance_max <= fim->tolerance_min) fim 118 drivers/staging/media/imx/imx-media-fim.c fim->tolerance_max = 0; fim 121 drivers/staging/media/imx/imx-media-fim.c if (!icap_enabled(fim)) fim 122 drivers/staging/media/imx/imx-media-fim.c fim->num_skip = max_t(int, fim->num_skip, 1); fim 124 drivers/staging/media/imx/imx-media-fim.c fim->counter = -fim->num_skip; fim 125 drivers/staging/media/imx/imx-media-fim.c fim->sum = 0; fim 128 drivers/staging/media/imx/imx-media-fim.c static void send_fim_event(struct imx_media_fim *fim, unsigned long error) fim 134 drivers/staging/media/imx/imx-media-fim.c v4l2_subdev_notify_event(fim->sd, &ev); fim 143 drivers/staging/media/imx/imx-media-fim.c static void frame_interval_monitor(struct imx_media_fim *fim, fim 150 drivers/staging/media/imx/imx-media-fim.c if (!fim->enabled || ++fim->counter <= 0) fim 154 drivers/staging/media/imx/imx-media-fim.c interval = ktime_to_ns(ktime_sub(timestamp, fim->last_ts)); fim 155 drivers/staging/media/imx/imx-media-fim.c error = abs(interval - NSEC_PER_USEC * (u64)fim->nominal); fim 161 drivers/staging/media/imx/imx-media-fim.c if (fim->tolerance_max && error >= fim->tolerance_max) { fim 162 drivers/staging/media/imx/imx-media-fim.c dev_dbg(fim->sd->dev, fim 165 drivers/staging/media/imx/imx-media-fim.c fim->counter--; fim 169 drivers/staging/media/imx/imx-media-fim.c fim->sum += error; fim 171 drivers/staging/media/imx/imx-media-fim.c if (fim->counter == fim->num_avg) { fim 172 drivers/staging/media/imx/imx-media-fim.c error_avg = DIV_ROUND_CLOSEST(fim->sum, fim->num_avg); fim 174 drivers/staging/media/imx/imx-media-fim.c if (error_avg > fim->tolerance_min) fim 177 drivers/staging/media/imx/imx-media-fim.c dev_dbg(fim->sd->dev, "FIM: error: %lu usec%s\n", fim 180 drivers/staging/media/imx/imx-media-fim.c fim->counter = 0; fim 181 drivers/staging/media/imx/imx-media-fim.c fim->sum = 0; fim 185 drivers/staging/media/imx/imx-media-fim.c fim->last_ts = timestamp; fim 187 drivers/staging/media/imx/imx-media-fim.c send_fim_event(fim, error_avg); fim 198 drivers/staging/media/imx/imx-media-fim.c struct imx_media_fim *fim = dev_id; fim 201 drivers/staging/media/imx/imx-media-fim.c spin_lock_irqsave(&fim->lock, flags); fim 203 drivers/staging/media/imx/imx-media-fim.c frame_interval_monitor(fim, timestamp); fim 205 drivers/staging/media/imx/imx-media-fim.c if (!completion_done(&fim->icap_first_event)) fim 206 drivers/staging/media/imx/imx-media-fim.c complete(&fim->icap_first_event); fim 208 drivers/staging/media/imx/imx-media-fim.c spin_unlock_irqrestore(&fim->lock, flags); fim 211 drivers/staging/media/imx/imx-media-fim.c static int fim_request_input_capture(struct imx_media_fim *fim) fim 213 drivers/staging/media/imx/imx-media-fim.c init_completion(&fim->icap_first_event); fim 215 drivers/staging/media/imx/imx-media-fim.c return mxc_request_input_capture(fim->icap_channel, fim 217 drivers/staging/media/imx/imx-media-fim.c fim->icap_flags, fim); fim 220 drivers/staging/media/imx/imx-media-fim.c static void fim_free_input_capture(struct imx_media_fim *fim) fim 222 drivers/staging/media/imx/imx-media-fim.c mxc_free_input_capture(fim->icap_channel, fim); fim 227 drivers/staging/media/imx/imx-media-fim.c static int fim_request_input_capture(struct imx_media_fim *fim) fim 232 drivers/staging/media/imx/imx-media-fim.c static void fim_free_input_capture(struct imx_media_fim *fim) fim 246 drivers/staging/media/imx/imx-media-fim.c static void fim_acquire_first_ts(struct imx_media_fim *fim) fim 250 drivers/staging/media/imx/imx-media-fim.c if (!fim->enabled || fim->num_skip > 0) fim 254 drivers/staging/media/imx/imx-media-fim.c &fim->icap_first_event, fim 257 drivers/staging/media/imx/imx-media-fim.c v4l2_warn(fim->sd, "wait first icap event timeout\n"); fim 263 drivers/staging/media/imx/imx-media-fim.c struct imx_media_fim *fim = container_of(ctrl->handler, fim 269 drivers/staging/media/imx/imx-media-fim.c spin_lock_irqsave(&fim->lock, flags); fim 275 drivers/staging/media/imx/imx-media-fim.c if (fim->stream_on) fim 283 drivers/staging/media/imx/imx-media-fim.c reset_fim(fim, false); fim 285 drivers/staging/media/imx/imx-media-fim.c spin_unlock_irqrestore(&fim->lock, flags); fim 369 drivers/staging/media/imx/imx-media-fim.c static int init_fim_controls(struct imx_media_fim *fim) fim 371 drivers/staging/media/imx/imx-media-fim.c struct v4l2_ctrl_handler *hdlr = &fim->ctrl_handler; fim 377 drivers/staging/media/imx/imx-media-fim.c fim->ctrl[i] = v4l2_ctrl_new_custom(hdlr, fim 381 drivers/staging/media/imx/imx-media-fim.c fim->icap_ctrl[i] = v4l2_ctrl_new_custom(hdlr, fim 389 drivers/staging/media/imx/imx-media-fim.c v4l2_ctrl_cluster(FIM_NUM_CONTROLS, fim->ctrl); fim 390 drivers/staging/media/imx/imx-media-fim.c v4l2_ctrl_cluster(FIM_NUM_ICAP_CONTROLS, fim->icap_ctrl); fim 406 drivers/staging/media/imx/imx-media-fim.c void imx_media_fim_eof_monitor(struct imx_media_fim *fim, ktime_t timestamp) fim 410 drivers/staging/media/imx/imx-media-fim.c spin_lock_irqsave(&fim->lock, flags); fim 412 drivers/staging/media/imx/imx-media-fim.c if (!icap_enabled(fim)) fim 413 drivers/staging/media/imx/imx-media-fim.c frame_interval_monitor(fim, timestamp); fim 415 drivers/staging/media/imx/imx-media-fim.c spin_unlock_irqrestore(&fim->lock, flags); fim 419 drivers/staging/media/imx/imx-media-fim.c int imx_media_fim_set_stream(struct imx_media_fim *fim, fim 426 drivers/staging/media/imx/imx-media-fim.c v4l2_ctrl_lock(fim->ctrl[FIM_CL_ENABLE]); fim 428 drivers/staging/media/imx/imx-media-fim.c if (fim->stream_on == on) fim 432 drivers/staging/media/imx/imx-media-fim.c spin_lock_irqsave(&fim->lock, flags); fim 433 drivers/staging/media/imx/imx-media-fim.c reset_fim(fim, true); fim 434 drivers/staging/media/imx/imx-media-fim.c update_fim_nominal(fim, fi); fim 435 drivers/staging/media/imx/imx-media-fim.c spin_unlock_irqrestore(&fim->lock, flags); fim 437 drivers/staging/media/imx/imx-media-fim.c if (icap_enabled(fim)) { fim 438 drivers/staging/media/imx/imx-media-fim.c ret = fim_request_input_capture(fim); fim 441 drivers/staging/media/imx/imx-media-fim.c fim_acquire_first_ts(fim); fim 444 drivers/staging/media/imx/imx-media-fim.c if (icap_enabled(fim)) fim 445 drivers/staging/media/imx/imx-media-fim.c fim_free_input_capture(fim); fim 448 drivers/staging/media/imx/imx-media-fim.c fim->stream_on = on; fim 450 drivers/staging/media/imx/imx-media-fim.c v4l2_ctrl_unlock(fim->ctrl[FIM_CL_ENABLE]); fim 454 drivers/staging/media/imx/imx-media-fim.c int imx_media_fim_add_controls(struct imx_media_fim *fim) fim 457 drivers/staging/media/imx/imx-media-fim.c return v4l2_ctrl_add_handler(fim->sd->ctrl_handler, fim 458 drivers/staging/media/imx/imx-media-fim.c &fim->ctrl_handler, NULL, false); fim 464 drivers/staging/media/imx/imx-media-fim.c struct imx_media_fim *fim; fim 467 drivers/staging/media/imx/imx-media-fim.c fim = devm_kzalloc(sd->dev, sizeof(*fim), GFP_KERNEL); fim 468 drivers/staging/media/imx/imx-media-fim.c if (!fim) fim 471 drivers/staging/media/imx/imx-media-fim.c fim->sd = sd; fim 473 drivers/staging/media/imx/imx-media-fim.c spin_lock_init(&fim->lock); fim 475 drivers/staging/media/imx/imx-media-fim.c ret = init_fim_controls(fim); fim 479 drivers/staging/media/imx/imx-media-fim.c return fim; fim 482 drivers/staging/media/imx/imx-media-fim.c void imx_media_fim_free(struct imx_media_fim *fim) fim 484 drivers/staging/media/imx/imx-media-fim.c v4l2_ctrl_handler_free(&fim->ctrl_handler); fim 230 drivers/staging/media/imx/imx-media.h void imx_media_fim_eof_monitor(struct imx_media_fim *fim, ktime_t timestamp); fim 231 drivers/staging/media/imx/imx-media.h int imx_media_fim_set_stream(struct imx_media_fim *fim, fim 234 drivers/staging/media/imx/imx-media.h int imx_media_fim_add_controls(struct imx_media_fim *fim); fim 236 drivers/staging/media/imx/imx-media.h void imx_media_fim_free(struct imx_media_fim *fim);