Lines Matching refs:input
180 static void tw5864_frame_interval_set(struct tw5864_input *input);
208 static int tw5864_input_std_get(struct tw5864_input *input, in tw5864_input_std_get() argument
211 struct tw5864_dev *dev = input->root; in tw5864_input_std_get()
212 u8 std_reg = tw_indir_readb(TW5864_INDIR_VIN_E(input->nr)); in tw5864_input_std_get()
225 static int tw5864_enable_input(struct tw5864_input *input) in tw5864_enable_input() argument
227 struct tw5864_dev *dev = input->root; in tw5864_enable_input()
228 int nr = input->nr; in tw5864_enable_input()
240 input->frame_seqno = 0; in tw5864_enable_input()
241 input->frame_gop_seqno = 0; in tw5864_enable_input()
242 input->h264_idr_pic_id = 0; in tw5864_enable_input()
244 input->reg_dsp_qp = input->qp; in tw5864_enable_input()
245 input->reg_dsp_ref_mvp_lambda = lambda_lookup_table[input->qp]; in tw5864_enable_input()
246 input->reg_dsp_i4x4_weight = intra4x4_lambda3[input->qp]; in tw5864_enable_input()
247 input->reg_emu = TW5864_EMU_EN_LPF | TW5864_EMU_EN_BHOST in tw5864_enable_input()
249 input->reg_dsp = nr /* channel id */ in tw5864_enable_input()
254 input->resolution = D1; in tw5864_enable_input()
256 d1_height = (input->std == STD_NTSC) ? 480 : 576; in tw5864_enable_input()
258 input->width = d1_width; in tw5864_enable_input()
259 input->height = d1_height; in tw5864_enable_input()
261 input->reg_interlacing = 0x4; in tw5864_enable_input()
263 switch (input->resolution) { in tw5864_enable_input()
266 frame_height_bus_value = input->height - 1; in tw5864_enable_input()
270 input->reg_dsp_codec |= TW5864_CIF_MAP_MD | TW5864_HD1_MAP_MD; in tw5864_enable_input()
271 input->reg_emu |= TW5864_DSP_FRAME_TYPE_D1; in tw5864_enable_input()
272 input->reg_interlacing = TW5864_DI_EN | TW5864_DSP_INTER_ST; in tw5864_enable_input()
277 input->height /= 2; in tw5864_enable_input()
278 input->width /= 2; in tw5864_enable_input()
280 frame_height_bus_value = input->height * 2 - 1; in tw5864_enable_input()
284 input->reg_dsp_codec |= TW5864_HD1_MAP_MD; in tw5864_enable_input()
285 input->reg_emu |= TW5864_DSP_FRAME_TYPE_D1; in tw5864_enable_input()
291 input->height /= 4; in tw5864_enable_input()
292 input->width /= 2; in tw5864_enable_input()
294 frame_height_bus_value = input->height * 2 - 1; in tw5864_enable_input()
298 input->reg_dsp_codec |= TW5864_CIF_MAP_MD; in tw5864_enable_input()
303 input->height /= 4; in tw5864_enable_input()
304 input->width /= 4; in tw5864_enable_input()
306 frame_height_bus_value = input->height * 2 - 1; in tw5864_enable_input()
310 input->reg_dsp_codec |= TW5864_CIF_MAP_MD; in tw5864_enable_input()
321 tw_indir_writeb(TW5864_INDIR_OUT_PIC_WIDTH(nr), input->width / 4); in tw5864_enable_input()
322 tw_indir_writeb(TW5864_INDIR_OUT_PIC_HEIGHT(nr), input->height / 4); in tw5864_enable_input()
328 input->width = 704; in tw5864_enable_input()
334 ((input->width / 16) << 8) | (input->height / 16)); in tw5864_enable_input()
345 tw5864_frame_interval_set(input); in tw5864_enable_input()
357 input->std == STD_NTSC ? 29 : 24); in tw5864_enable_input()
364 input->enabled = 1; in tw5864_enable_input()
370 void tw5864_request_encoded_frame(struct tw5864_input *input) in tw5864_request_encoded_frame() argument
372 struct tw5864_dev *dev = input->root; in tw5864_request_encoded_frame()
376 tw_writel(TW5864_EMU, input->reg_emu); in tw5864_request_encoded_frame()
377 tw_writel(TW5864_INTERLACING, input->reg_interlacing); in tw5864_request_encoded_frame()
378 tw_writel(TW5864_DSP, input->reg_dsp); in tw5864_request_encoded_frame()
380 tw_writel(TW5864_DSP_QP, input->reg_dsp_qp); in tw5864_request_encoded_frame()
381 tw_writel(TW5864_DSP_REF_MVP_LAMBDA, input->reg_dsp_ref_mvp_lambda); in tw5864_request_encoded_frame()
382 tw_writel(TW5864_DSP_I4x4_WEIGHT, input->reg_dsp_i4x4_weight); in tw5864_request_encoded_frame()
387 if (input->frame_gop_seqno == 0) { in tw5864_request_encoded_frame()
390 input->h264_idr_pic_id++; in tw5864_request_encoded_frame()
391 input->h264_idr_pic_id &= TW5864_DSP_REF_FRM; in tw5864_request_encoded_frame()
397 tw5864_prepare_frame_headers(input); in tw5864_request_encoded_frame()
400 ((input->tail_nb_bits + 24) << TW5864_VLC_BIT_ALIGN_SHIFT) | in tw5864_request_encoded_frame()
401 input->reg_dsp_qp); in tw5864_request_encoded_frame()
404 2 * input->nr); in tw5864_request_encoded_frame()
414 static int tw5864_disable_input(struct tw5864_input *input) in tw5864_disable_input() argument
416 struct tw5864_dev *dev = input->root; in tw5864_disable_input()
419 dev_dbg(&dev->pci->dev, "Disabling channel %d\n", input->nr); in tw5864_disable_input()
422 input->enabled = 0; in tw5864_disable_input()
429 struct tw5864_input *input = vb2_get_drv_priv(q); in tw5864_start_streaming() local
432 ret = tw5864_enable_input(input); in tw5864_start_streaming()
436 while (!list_empty(&input->active)) { in tw5864_start_streaming()
437 struct tw5864_buf *buf = list_entry(input->active.next, in tw5864_start_streaming()
449 struct tw5864_input *input = vb2_get_drv_priv(q); in tw5864_stop_streaming() local
451 tw5864_disable_input(input); in tw5864_stop_streaming()
453 spin_lock_irqsave(&input->slock, flags); in tw5864_stop_streaming()
454 if (input->vb) { in tw5864_stop_streaming()
455 vb2_buffer_done(&input->vb->vb.vb2_buf, VB2_BUF_STATE_ERROR); in tw5864_stop_streaming()
456 input->vb = NULL; in tw5864_stop_streaming()
458 while (!list_empty(&input->active)) { in tw5864_stop_streaming()
459 struct tw5864_buf *buf = list_entry(input->active.next, in tw5864_stop_streaming()
465 spin_unlock_irqrestore(&input->slock, flags); in tw5864_stop_streaming()
479 struct tw5864_input *input = in tw5864_s_ctrl() local
481 struct tw5864_dev *dev = input->root; in tw5864_s_ctrl()
486 tw_indir_writeb(TW5864_INDIR_VIN_A_BRIGHT(input->nr), in tw5864_s_ctrl()
490 tw_indir_writeb(TW5864_INDIR_VIN_7_HUE(input->nr), in tw5864_s_ctrl()
494 tw_indir_writeb(TW5864_INDIR_VIN_9_CNTRST(input->nr), in tw5864_s_ctrl()
498 tw_indir_writeb(TW5864_INDIR_VIN_B_SAT_U(input->nr), in tw5864_s_ctrl()
500 tw_indir_writeb(TW5864_INDIR_VIN_C_SAT_V(input->nr), in tw5864_s_ctrl()
504 input->gop = ctrl->val; in tw5864_s_ctrl()
507 spin_lock_irqsave(&input->slock, flags); in tw5864_s_ctrl()
508 input->qp = ctrl->val; in tw5864_s_ctrl()
509 input->reg_dsp_qp = input->qp; in tw5864_s_ctrl()
510 input->reg_dsp_ref_mvp_lambda = lambda_lookup_table[input->qp]; in tw5864_s_ctrl()
511 input->reg_dsp_i4x4_weight = intra4x4_lambda3[input->qp]; in tw5864_s_ctrl()
512 spin_unlock_irqrestore(&input->slock, flags); in tw5864_s_ctrl()
515 memset(input->md_threshold_grid_values, ctrl->val, in tw5864_s_ctrl()
516 sizeof(input->md_threshold_grid_values)); in tw5864_s_ctrl()
522 memcpy(input->md_threshold_grid_values, in tw5864_s_ctrl()
523 input->md_threshold_grid_ctrl->p_new.p_u16, in tw5864_s_ctrl()
524 sizeof(input->md_threshold_grid_values)); in tw5864_s_ctrl()
533 struct tw5864_input *input = video_drvdata(file); in tw5864_fmt_vid_cap() local
536 switch (input->std) { in tw5864_fmt_vid_cap()
558 struct tw5864_input *input = video_drvdata(file); in tw5864_enum_input() local
559 struct tw5864_dev *dev = input->root; in tw5864_enum_input()
561 u8 indir_0x000 = tw_indir_readb(TW5864_INDIR_VIN_0(input->nr)); in tw5864_enum_input()
562 u8 indir_0x00d = tw_indir_readb(TW5864_INDIR_VIN_D(input->nr)); in tw5864_enum_input()
570 snprintf(i->name, sizeof(i->name), "Encoder %d", input->nr); in tw5864_enum_input()
602 struct tw5864_input *input = video_drvdata(file); in tw5864_querycap() local
606 input->nr); in tw5864_querycap()
612 struct tw5864_input *input = video_drvdata(file); in tw5864_querystd() local
616 ret = tw5864_input_std_get(input, &tw_std); in tw5864_querystd()
626 struct tw5864_input *input = video_drvdata(file); in tw5864_g_std() local
628 *std = input->v4l2_std; in tw5864_g_std()
634 struct tw5864_input *input = video_drvdata(file); in tw5864_s_std() local
635 struct tw5864_dev *dev = input->root; in tw5864_s_std()
637 input->v4l2_std = std; in tw5864_s_std()
638 input->std = tw5864_from_v4l2_std(std); in tw5864_s_std()
639 tw_indir_writeb(TW5864_INDIR_VIN_E(input->nr), input->std); in tw5864_s_std()
668 static void tw5864_frame_interval_set(struct tw5864_input *input) in tw5864_frame_interval_set() argument
693 struct tw5864_dev *dev = input->root; in tw5864_frame_interval_set()
696 int std_max_fps = input->std == STD_NTSC ? 30 : 25; in tw5864_frame_interval_set()
698 for (shift = 0; shift < std_max_fps; shift += input->frame_interval) in tw5864_frame_interval_set()
701 tw_writel(TW5864_H264EN_RATE_CNTL_LO_WORD(input->nr, 0), in tw5864_frame_interval_set()
703 tw_writel(TW5864_H264EN_RATE_CNTL_HI_WORD(input->nr, 0), in tw5864_frame_interval_set()
707 static int tw5864_frameinterval_get(struct tw5864_input *input, in tw5864_frameinterval_get() argument
710 struct tw5864_dev *dev = input->root; in tw5864_frameinterval_get()
712 switch (input->std) { in tw5864_frameinterval_get()
724 input->std); in tw5864_frameinterval_get()
734 struct tw5864_input *input = video_drvdata(file); in tw5864_enum_framesizes() local
743 fsize->discrete.height = input->std == STD_NTSC ? 480 : 576; in tw5864_enum_framesizes()
751 struct tw5864_input *input = video_drvdata(file); in tw5864_enum_frameintervals() local
753 int std_max_fps = input->std == STD_NTSC ? 30 : 25; in tw5864_enum_frameintervals()
768 ret = tw5864_frameinterval_get(input, &frameinterval); in tw5864_enum_frameintervals()
783 struct tw5864_input *input = video_drvdata(file); in tw5864_g_parm() local
789 ret = tw5864_frameinterval_get(input, &cp->timeperframe); in tw5864_g_parm()
793 cp->timeperframe.numerator *= input->frame_interval; in tw5864_g_parm()
803 struct tw5864_input *input = video_drvdata(file); in tw5864_s_parm() local
808 ret = tw5864_frameinterval_get(input, &time_base); in tw5864_s_parm()
813 t->numerator = time_base.numerator * input->frame_interval; in tw5864_s_parm()
821 input->frame_interval = t->numerator / time_base.numerator; in tw5864_s_parm()
822 if (input->frame_interval < 1) in tw5864_s_parm()
823 input->frame_interval = 1; in tw5864_s_parm()
824 tw5864_frame_interval_set(input); in tw5864_s_parm()
849 struct tw5864_input *input = video_drvdata(file); in tw5864_g_reg() local
850 struct tw5864_dev *dev = input->root; in tw5864_g_reg()
871 struct tw5864_input *input = video_drvdata(file); in tw5864_s_reg() local
872 struct tw5864_dev *dev = input->root; in tw5864_s_reg()
1097 static int tw5864_video_input_init(struct tw5864_input *input, int video_nr) in tw5864_video_input_init() argument
1099 struct tw5864_dev *dev = input->root; in tw5864_video_input_init()
1101 struct v4l2_ctrl_handler *hdl = &input->hdl; in tw5864_video_input_init()
1103 mutex_init(&input->lock); in tw5864_video_input_init()
1104 spin_lock_init(&input->slock); in tw5864_video_input_init()
1107 INIT_LIST_HEAD(&input->active); in tw5864_video_input_init()
1108 input->vidq.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; in tw5864_video_input_init()
1109 input->vidq.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; in tw5864_video_input_init()
1110 input->vidq.io_modes = VB2_MMAP | VB2_READ | VB2_DMABUF; in tw5864_video_input_init()
1111 input->vidq.ops = &tw5864_video_qops; in tw5864_video_input_init()
1112 input->vidq.mem_ops = &vb2_dma_contig_memops; in tw5864_video_input_init()
1113 input->vidq.drv_priv = input; in tw5864_video_input_init()
1114 input->vidq.gfp_flags = 0; in tw5864_video_input_init()
1115 input->vidq.buf_struct_size = sizeof(struct tw5864_buf); in tw5864_video_input_init()
1116 input->vidq.lock = &input->lock; in tw5864_video_input_init()
1117 input->vidq.min_buffers_needed = 2; in tw5864_video_input_init()
1118 input->vidq.dev = &input->root->pci->dev; in tw5864_video_input_init()
1119 ret = vb2_queue_init(&input->vidq); in tw5864_video_input_init()
1123 input->vdev = tw5864_video_template; in tw5864_video_input_init()
1124 input->vdev.v4l2_dev = &input->root->v4l2_dev; in tw5864_video_input_init()
1125 input->vdev.lock = &input->lock; in tw5864_video_input_init()
1126 input->vdev.queue = &input->vidq; in tw5864_video_input_init()
1127 video_set_drvdata(&input->vdev, input); in tw5864_video_input_init()
1150 input->md_threshold_grid_ctrl = in tw5864_video_input_init()
1156 input->vdev.ctrl_handler = hdl; in tw5864_video_input_init()
1159 input->qp = QP_VALUE; in tw5864_video_input_init()
1160 input->gop = GOP_SIZE; in tw5864_video_input_init()
1161 input->frame_interval = 1; in tw5864_video_input_init()
1163 ret = video_register_device(&input->vdev, VFL_TYPE_VIDEO, video_nr); in tw5864_video_input_init()
1167 dev_info(&input->root->pci->dev, "Registered video device %s\n", in tw5864_video_input_init()
1168 video_device_node_name(&input->vdev)); in tw5864_video_input_init()
1174 input->v4l2_std = V4L2_STD_NTSC_M; in tw5864_video_input_init()
1175 input->std = STD_NTSC; in tw5864_video_input_init()
1186 mutex_destroy(&input->lock); in tw5864_video_input_init()
1216 void tw5864_prepare_frame_headers(struct tw5864_input *input) in tw5864_prepare_frame_headers() argument
1218 struct tw5864_buf *vb = input->vb; in tw5864_prepare_frame_headers()
1224 spin_lock_irqsave(&input->slock, flags); in tw5864_prepare_frame_headers()
1225 if (list_empty(&input->active)) { in tw5864_prepare_frame_headers()
1226 spin_unlock_irqrestore(&input->slock, flags); in tw5864_prepare_frame_headers()
1227 input->vb = NULL; in tw5864_prepare_frame_headers()
1230 vb = list_first_entry(&input->active, struct tw5864_buf, list); in tw5864_prepare_frame_headers()
1232 spin_unlock_irqrestore(&input->slock, flags); in tw5864_prepare_frame_headers()
1253 if (input->frame_gop_seqno == 0) in tw5864_prepare_frame_headers()
1254 tw5864_h264_put_stream_header(&dst, &dst_space, input->qp, in tw5864_prepare_frame_headers()
1255 input->width, input->height); in tw5864_prepare_frame_headers()
1258 tw5864_h264_put_slice_header(&dst, &dst_space, input->h264_idr_pic_id, in tw5864_prepare_frame_headers()
1259 input->frame_gop_seqno, in tw5864_prepare_frame_headers()
1260 &input->tail_nb_bits, &input->tail); in tw5864_prepare_frame_headers()
1261 input->vb = vb; in tw5864_prepare_frame_headers()
1262 input->buf_cur_ptr = dst; in tw5864_prepare_frame_headers()
1263 input->buf_cur_space_left = dst_space; in tw5864_prepare_frame_headers()
1300 struct tw5864_input *input = frame->input; in tw5864_is_motion_triggered() local
1306 const u16 thresh = input->md_threshold_grid_values[i]; in tw5864_is_motion_triggered()
1365 struct tw5864_input *input = frame->input; in tw5864_handle_frame() local
1366 struct tw5864_dev *dev = input->root; in tw5864_handle_frame()
1370 u8 *dst = input->buf_cur_ptr; in tw5864_handle_frame()
1386 spin_lock_irqsave(&input->slock, flags); in tw5864_handle_frame()
1387 vb = input->vb; in tw5864_handle_frame()
1388 input->vb = NULL; in tw5864_handle_frame()
1389 spin_unlock_irqrestore(&input->slock, flags); in tw5864_handle_frame()
1402 if (input->buf_cur_space_left < frame_len * 5 / 4) { in tw5864_handle_frame()
1405 input->buf_cur_space_left, frame_len); in tw5864_handle_frame()
1409 for (i = 0; i < 8 - input->tail_nb_bits; i++) in tw5864_handle_frame()
1413 dst[0] = (input->tail & tail_mask) | (vlc_first_byte & vlc_mask); in tw5864_handle_frame()
1453 v4l2_event_queue(&input->vdev, &ev); in tw5864_handle_frame()