int32_t scale_start(void) { enum scale_drv_rtn rtn = SCALE_RTN_SUCCESS; int ret = 0; SCALE_TRACE("SCALE DRV: scale_start: %d \n", g_path->scale_mode); dcam_resize_start(); if (g_path->output_size.w > SCALE_LINE_BUF_LENGTH && SCALE_MODE_NORMAL == g_path->scale_mode) { rtn = SCALE_RTN_SC_ERR; SCALE_RTN_IF_ERR; } rtn = _scale_alloc_tmp_buf(); if(rtn) { printk("SCALE DRV: No mem to alloc tmp buf \n"); goto exit; } g_path->slice_in_height = 0; g_path->slice_out_height = 0; g_path->is_last_slice = 0; REG_OWR(SCALE_INT_CLR, SCALE_IRQ_BIT); REG_OWR(SCALE_INT_MASK, SCALE_IRQ_BIT); rtn = _scale_trim(); if(rtn) goto exit; rtn = _scale_cfg_scaler(); if(rtn) goto exit; ret = request_irq(SCALE_IRQ, _scale_isr_root, IRQF_SHARED, "SCALE", &g_scale_irq); if (ret) { printk("SCALE DRV: scale_start,error %d \n", ret); rtn = SCALE_RTN_MAX; } if (SCALE_MODE_SLICE == g_path->scale_mode) { g_path->slice_in_height += g_path->slice_height; } REG_OWR(SCALE_BASE, 1 << 2); _scale_reg_trace(); REG_OWR(SCALE_CFG, 1); atomic_inc(&g_path->start_flag); return SCALE_RTN_SUCCESS; exit: dcam_resize_end(); _scale_free_tmp_buf(); printk("SCALE DRV: ret %d \n", rtn); return rtn; }
static long scale_k_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { int ret = 0; struct scale_k_private *scale_private; struct scale_k_file *fd; struct scale_frame_param_t frame_params; struct scale_slice_param_t slice_params; fd = file->private_data; if (!fd) { ret = - EFAULT; printk("scale_k_ioctl error: fd null \n"); goto ioctl_exit; } scale_private = fd->scale_private; if (!scale_private) { ret = -EFAULT; printk("scale_k_ioctl erro: scale private null \n"); goto ioctl_exit; } switch (cmd) { case SCALE_IO_START: down(&scale_private->start_sem); ret = scale_k_module_en(fd->dn); if (unlikely(ret)) { printk("rot_k_ioctl erro: scale_module_en\n"); up(&scale_private->start_sem); goto ioctl_exit; } ret = scale_k_isr_reg(scale_k_irq, &fd->drv_private); if (unlikely(ret)) { printk("rot_k_ioctl error: scale_k_isr_reg\n"); scale_k_module_dis(fd->dn); up(&scale_private->start_sem); goto ioctl_exit; } ret = copy_from_user(&frame_params, (struct scale_frame_param_t *)arg, sizeof(frame_params)); if (ret) { printk("rot_k_ioctl error: get frame param info \n"); scale_k_module_dis(fd->dn); up(&scale_private->start_sem); goto ioctl_exit; } ret = scale_k_start(&frame_params, &fd->drv_private.path_info); if (ret) { printk("rot_k_ioctl error: frame start \n"); scale_k_module_dis(fd->dn); up(&scale_private->start_sem); goto ioctl_exit; } ret = down_timeout(&fd->scale_done_sem, msecs_to_jiffies(5000)); if (ret) { printk("scale_k_ioctl error: interruptible time out\n"); goto ioctl_out; } scale_k_stop(); scale_k_module_dis(fd->dn); up(&scale_private->start_sem); break; case SCALE_IO_CONTINUE: /*Caution: slice scale is not supported by current driver.Please do not use it*/ ret = copy_from_user(&slice_params, (struct scale_slice_param_t *)arg, sizeof(slice_params)); if (ret) { printk("rot_k_ioctl error: get slice param info \n"); goto ioctl_exit; } ret = scale_k_continue(&slice_params, &fd->drv_private.path_info); if (ret) { printk("rot_k_ioctl error: continue \n"); } break; default: break; } ioctl_exit: return ret; ioctl_out: dcam_resize_end(); scale_k_stop(); scale_k_module_dis(fd->dn); up(&scale_private->start_sem); return ret; }