Ejemplo n.º 1
0
static int vfe_proc_general(struct msm_vfe_command_8k *cmd)
{
	int rc = 0;

	CDBG("vfe_proc_general: cmdID = %d\n", cmd->id);

	switch (cmd->id) {
	case VFE_CMD_ID_RESET:
		msm_camio_vfe_blk_reset();
		msm_camio_camif_pad_reg_reset_2();
		vfe_reset();
		break;

	case VFE_CMD_ID_START: {
		struct vfe_cmd_start start;
		if (copy_from_user(&start,
			(void __user *) cmd->value, cmd->length))
			rc = -EFAULT;

		/* msm_camio_camif_pad_reg_reset_2(); */
		msm_camio_camif_pad_reg_reset();
		vfe_start(&start);
	}
		break;

	case VFE_CMD_ID_CAMIF_CONFIG: {
		struct vfe_cmd_camif_config camif;
		if (copy_from_user(&camif,
			(void __user *) cmd->value, cmd->length))
			rc = -EFAULT;

		vfe_camif_config(&camif);
	}
		break;

	case VFE_CMD_ID_BLACK_LEVEL_CONFIG: {
		struct vfe_cmd_black_level_config bl;
		if (copy_from_user(&bl,
			(void __user *) cmd->value, cmd->length))
			rc = -EFAULT;

		vfe_black_level_config(&bl);
	}
		break;

	case VFE_CMD_ID_ROLL_OFF_CONFIG: {
		struct vfe_cmd_roll_off_config rolloff;
		if (copy_from_user(&rolloff,
			(void __user *) cmd->value, cmd->length))
			rc = -EFAULT;

		vfe_roll_off_config(&rolloff);
	}
		break;

	case VFE_CMD_ID_DEMUX_CHANNEL_GAIN_CONFIG: {
		struct vfe_cmd_demux_channel_gain_config demuxc;
		if (copy_from_user(&demuxc,
			(void __user *) cmd->value, cmd->length))
			rc = -EFAULT;

		/* demux is always enabled.  */
		vfe_demux_channel_gain_config(&demuxc);
	}
		break;

	case VFE_CMD_ID_DEMOSAIC_CONFIG: {
		struct vfe_cmd_demosaic_config demosaic;
		if (copy_from_user(&demosaic,
			(void __user *) cmd->value, cmd->length))
			rc = -EFAULT;

		vfe_demosaic_config(&demosaic);
	}
		break;

	case VFE_CMD_ID_FOV_CROP_CONFIG:
	case VFE_CMD_ID_FOV_CROP_UPDATE: {
		struct vfe_cmd_fov_crop_config fov;
		if (copy_from_user(&fov,
			(void __user *) cmd->value, cmd->length))
			rc = -EFAULT;

		vfe_fov_crop_config(&fov);
	}
		break;

	case VFE_CMD_ID_MAIN_SCALER_CONFIG:
	case VFE_CMD_ID_MAIN_SCALER_UPDATE: {
		struct vfe_cmd_main_scaler_config mainds;
		if (copy_from_user(&mainds,
			(void __user *) cmd->value, cmd->length))
			rc = -EFAULT;

		vfe_main_scaler_config(&mainds);
	}
		break;

	case VFE_CMD_ID_WHITE_BALANCE_CONFIG:
	case VFE_CMD_ID_WHITE_BALANCE_UPDATE: {
		struct vfe_cmd_white_balance_config wb;
		if (copy_from_user(&wb,
			(void __user *)	cmd->value, cmd->length))
			rc = -EFAULT;

		vfe_white_balance_config(&wb);
	}
		break;

	case VFE_CMD_ID_COLOR_CORRECTION_CONFIG:
	case VFE_CMD_ID_COLOR_CORRECTION_UPDATE: {
		struct vfe_cmd_color_correction_config cc;
		if (copy_from_user(&cc,
			(void __user *) cmd->value, cmd->length))
			rc = -EFAULT;

		vfe_color_correction_config(&cc);
	}
		break;

	case VFE_CMD_ID_LA_CONFIG: {
		struct vfe_cmd_la_config la;
		if (copy_from_user(&la,
			(void __user *) cmd->value, cmd->length))
			rc = -EFAULT;

		vfe_la_config(&la);
	}
		break;

	case VFE_CMD_ID_RGB_GAMMA_CONFIG: {
		struct vfe_cmd_rgb_gamma_config rgb;
		if (copy_from_user(&rgb,
			(void __user *) cmd->value, cmd->length))
			rc = -EFAULT;

		rc = vfe_rgb_gamma_config(&rgb);
	}
		break;

	case VFE_CMD_ID_CHROMA_ENHAN_CONFIG:
	case VFE_CMD_ID_CHROMA_ENHAN_UPDATE: {
		struct vfe_cmd_chroma_enhan_config chrom;
		if (copy_from_user(&chrom,
			(void __user *) cmd->value, cmd->length))
			rc = -EFAULT;

		vfe_chroma_enhan_config(&chrom);
	}
		break;

	case VFE_CMD_ID_CHROMA_SUPPRESSION_CONFIG:
	case VFE_CMD_ID_CHROMA_SUPPRESSION_UPDATE: {
		struct vfe_cmd_chroma_suppression_config chromsup;
		if (copy_from_user(&chromsup,
			(void __user *) cmd->value, cmd->length))
			rc = -EFAULT;

		vfe_chroma_sup_config(&chromsup);
	}
		break;

	case VFE_CMD_ID_ASF_CONFIG: {
		struct vfe_cmd_asf_config asf;
		if (copy_from_user(&asf,
			(void __user *) cmd->value, cmd->length))
			rc = -EFAULT;

		vfe_asf_config(&asf);
	}
		break;

	case VFE_CMD_ID_SCALER2Y_CONFIG:
	case VFE_CMD_ID_SCALER2Y_UPDATE: {
		struct vfe_cmd_scaler2_config ds2y;
		if (copy_from_user(&ds2y,
			(void __user *) cmd->value, cmd->length))
			rc = -EFAULT;

		vfe_scaler2y_config(&ds2y);
	}
		break;

	case VFE_CMD_ID_SCALER2CbCr_CONFIG:
	case VFE_CMD_ID_SCALER2CbCr_UPDATE: {
		struct vfe_cmd_scaler2_config ds2cbcr;
		if (copy_from_user(&ds2cbcr,
			(void __user *) cmd->value, cmd->length))
			rc = -EFAULT;

		vfe_scaler2cbcr_config(&ds2cbcr);
	}
		break;

	case VFE_CMD_ID_CHROMA_SUBSAMPLE_CONFIG: {
		struct vfe_cmd_chroma_subsample_config sub;
		if (copy_from_user(&sub,
			(void __user *) cmd->value, cmd->length))
			rc = -EFAULT;

		vfe_chroma_subsample_config(&sub);
	}
		break;

	case VFE_CMD_ID_FRAME_SKIP_CONFIG: {
		struct vfe_cmd_frame_skip_config fskip;
		if (copy_from_user(&fskip,
			(void __user *) cmd->value, cmd->length))
			rc = -EFAULT;

		vfe_frame_skip_config(&fskip);
	}
		break;

	case VFE_CMD_ID_OUTPUT_CLAMP_CONFIG: {
		struct vfe_cmd_output_clamp_config clamp;
		if (copy_from_user(&clamp,
			(void __user *) cmd->value, cmd->length))
			rc = -EFAULT;

		vfe_output_clamp_config(&clamp);
	}
		break;

	/* module update commands */
	case VFE_CMD_ID_BLACK_LEVEL_UPDATE: {
		struct vfe_cmd_black_level_config blk;
		if (copy_from_user(&blk,
			(void __user *) cmd->value, cmd->length))
			rc = -EFAULT;

		vfe_black_level_update(&blk);
	}
		break;

	case VFE_CMD_ID_DEMUX_CHANNEL_GAIN_UPDATE: {
		struct vfe_cmd_demux_channel_gain_config dmu;
		if (copy_from_user(&dmu,
			(void __user *) cmd->value, cmd->length))
			rc = -EFAULT;

		vfe_demux_channel_gain_update(&dmu);
	}
		break;

	case VFE_CMD_ID_DEMOSAIC_BPC_UPDATE: {
		struct vfe_cmd_demosaic_bpc_update demo_bpc;
		if (copy_from_user(&demo_bpc,
			(void __user *) cmd->value, cmd->length))
			rc = -EFAULT;

		vfe_demosaic_bpc_update(&demo_bpc);
	}
		break;

	case VFE_CMD_ID_DEMOSAIC_ABF_UPDATE: {
		struct vfe_cmd_demosaic_abf_update demo_abf;
		if (copy_from_user(&demo_abf,
			(void __user *) cmd->value, cmd->length))
			rc = -EFAULT;

		vfe_demosaic_abf_update(&demo_abf);
	}
		break;

	case VFE_CMD_ID_LA_UPDATE: {
		struct vfe_cmd_la_config la;
		if (copy_from_user(&la,
			(void __user *) cmd->value, cmd->length))
			rc = -EFAULT;

		vfe_la_update(&la);
	}
		break;

	case VFE_CMD_ID_RGB_GAMMA_UPDATE: {
		struct vfe_cmd_rgb_gamma_config rgb;
		if (copy_from_user(&rgb,
			(void __user *) cmd->value, cmd->length))
			rc = -EFAULT;

		rc = vfe_rgb_gamma_update(&rgb);
	}
		break;

	case VFE_CMD_ID_ASF_UPDATE: {
		struct vfe_cmd_asf_update asf;
		if (copy_from_user(&asf,
			(void __user *) cmd->value, cmd->length))
			rc = -EFAULT;

		vfe_asf_update(&asf);
	}
		break;

	case VFE_CMD_ID_FRAME_SKIP_UPDATE: {
		struct vfe_cmd_frame_skip_update fskip;
		if (copy_from_user(&fskip,
			(void __user *) cmd->value, cmd->length))
			rc = -EFAULT;

		vfe_frame_skip_update(&fskip);
	}
		break;

	case VFE_CMD_ID_CAMIF_FRAME_UPDATE: {
		struct vfe_cmds_camif_frame fup;
		if (copy_from_user(&fup,
			(void __user *) cmd->value, cmd->length))
			rc = -EFAULT;

		vfe_camif_frame_update(&fup);
	}
		break;

	/* stats update commands */
	case VFE_CMD_ID_STATS_AUTOFOCUS_UPDATE: {
		struct vfe_cmd_stats_af_update afup;
		if (copy_from_user(&afup,
			(void __user *) cmd->value, cmd->length))
			rc = -EFAULT;

		vfe_stats_update_af(&afup);
	}
		break;

	case VFE_CMD_ID_STATS_WB_EXP_UPDATE: {
		struct vfe_cmd_stats_wb_exp_update wbexp;
		if (copy_from_user(&wbexp,
			(void __user *) cmd->value, cmd->length))
			rc = -EFAULT;

		vfe_stats_update_wb_exp(&wbexp);
	}
		break;

	/* control of start, stop, update, etc... */
	case VFE_CMD_ID_STOP:
		vfe_stop();
		break;

	case VFE_CMD_ID_GET_HW_VERSION:
		break;

	/* stats */
	case VFE_CMD_ID_STATS_SETTING: {
		struct vfe_cmd_stats_setting stats;
		if (copy_from_user(&stats,
			(void __user *) cmd->value, cmd->length))
			rc = -EFAULT;

		vfe_stats_setting(&stats);
	}
		break;

	case VFE_CMD_ID_STATS_AUTOFOCUS_START: {
		struct vfe_cmd_stats_af_start af;
		if (copy_from_user(&af,
			(void __user *) cmd->value, cmd->length))
			rc = -EFAULT;

		vfe_stats_start_af(&af);
	}
		break;

	case VFE_CMD_ID_STATS_AUTOFOCUS_STOP:
		vfe_stats_af_stop();
		break;

	case VFE_CMD_ID_STATS_WB_EXP_START: {
		struct vfe_cmd_stats_wb_exp_start awexp;
		if (copy_from_user(&awexp,
			(void __user *) cmd->value, cmd->length))
			rc = -EFAULT;

		vfe_stats_start_wb_exp(&awexp);
	}
		break;

	case VFE_CMD_ID_STATS_WB_EXP_STOP:
		vfe_stats_wb_exp_stop();
		break;

	case VFE_CMD_ID_ASYNC_TIMER_SETTING:
		break;

	case VFE_CMD_ID_UPDATE:
		vfe_update();
		break;

	/* test gen */
	case VFE_CMD_ID_TEST_GEN_START:
		break;

/*
  acknowledge from upper layer
	these are not in general command.

	case VFE_CMD_ID_OUTPUT1_ACK:
		break;
	case VFE_CMD_ID_OUTPUT2_ACK:
		break;
	case VFE_CMD_ID_EPOCH1_ACK:
		break;
	case VFE_CMD_ID_EPOCH2_ACK:
		break;
	case VFE_CMD_ID_STATS_AUTOFOCUS_ACK:
		break;
	case VFE_CMD_ID_STATS_WB_EXP_ACK:
		break;
*/

	default:
		break;
	} /* switch */

	return rc;
}
Ejemplo n.º 2
0
static int vfe_proc_general(struct msm_vfe_command_8k *cmd)
{
	int rc = 0;

	CDBG("%s: cmdID = %d\n", __func__, cmd->id);

	switch (cmd->id) {
	case VFE_CMD_ID_RESET:
		msm_camio_vfe_blk_reset();
		msm_camio_camif_pad_reg_reset_2();
		vfe_reset();
		break;

	case VFE_CMD_ID_START: {
		struct vfe_cmd_start start;
			CHECKED_COPY_FROM_USER(&start);

		
		msm_camio_camif_pad_reg_reset();
		vfe_start(&start);
	}
		break;

	case VFE_CMD_ID_CAMIF_CONFIG: {
		struct vfe_cmd_camif_config camif;
			CHECKED_COPY_FROM_USER(&camif);

		vfe_camif_config(&camif);
	}
		break;

	case VFE_CMD_ID_BLACK_LEVEL_CONFIG: {
		struct vfe_cmd_black_level_config bl;
			CHECKED_COPY_FROM_USER(&bl);

		vfe_black_level_config(&bl);
	}
		break;

	case VFE_CMD_ID_ROLL_OFF_CONFIG:{
			
			struct vfe_cmd_roll_off_config *rolloff =
			    kmalloc(sizeof(struct vfe_cmd_roll_off_config),
				    GFP_KERNEL);
			if (!rolloff) {
				pr_err("%s: out of memory\n", __func__);
				rc = -ENOMEM;
				break;
			}
			
			do {
				CHECKED_COPY_FROM_USER(rolloff);
				vfe_roll_off_config(rolloff);
			} while (0);
			kfree(rolloff);
	}
		break;

	case VFE_CMD_ID_DEMUX_CHANNEL_GAIN_CONFIG: {
		struct vfe_cmd_demux_channel_gain_config demuxc;
			CHECKED_COPY_FROM_USER(&demuxc);

		
		vfe_demux_channel_gain_config(&demuxc);
	}
		break;

	case VFE_CMD_ID_DEMOSAIC_CONFIG: {
		struct vfe_cmd_demosaic_config demosaic;
			CHECKED_COPY_FROM_USER(&demosaic);

		vfe_demosaic_config(&demosaic);
	}
		break;

	case VFE_CMD_ID_FOV_CROP_CONFIG:
	case VFE_CMD_ID_FOV_CROP_UPDATE: {
		struct vfe_cmd_fov_crop_config fov;
			CHECKED_COPY_FROM_USER(&fov);

		vfe_fov_crop_config(&fov);
	}
		break;

	case VFE_CMD_ID_MAIN_SCALER_CONFIG:
	case VFE_CMD_ID_MAIN_SCALER_UPDATE: {
		struct vfe_cmd_main_scaler_config mainds;
			CHECKED_COPY_FROM_USER(&mainds);

		vfe_main_scaler_config(&mainds);
	}
		break;

	case VFE_CMD_ID_WHITE_BALANCE_CONFIG:
	case VFE_CMD_ID_WHITE_BALANCE_UPDATE: {
		struct vfe_cmd_white_balance_config wb;
			CHECKED_COPY_FROM_USER(&wb);

		vfe_white_balance_config(&wb);
	}
		break;

	case VFE_CMD_ID_COLOR_CORRECTION_CONFIG:
	case VFE_CMD_ID_COLOR_CORRECTION_UPDATE: {
		struct vfe_cmd_color_correction_config cc;
			CHECKED_COPY_FROM_USER(&cc);

		vfe_color_correction_config(&cc);
	}
		break;

	case VFE_CMD_ID_LA_CONFIG: {
		struct vfe_cmd_la_config la;
			CHECKED_COPY_FROM_USER(&la);

		vfe_la_config(&la);
	}
		break;

	case VFE_CMD_ID_RGB_GAMMA_CONFIG: {
		struct vfe_cmd_rgb_gamma_config rgb;
			CHECKED_COPY_FROM_USER(&rgb);

		rc = vfe_rgb_gamma_config(&rgb);
	}
		break;

	case VFE_CMD_ID_CHROMA_ENHAN_CONFIG:
	case VFE_CMD_ID_CHROMA_ENHAN_UPDATE: {
		struct vfe_cmd_chroma_enhan_config chrom;
			CHECKED_COPY_FROM_USER(&chrom);

		vfe_chroma_enhan_config(&chrom);
	}
		break;

	case VFE_CMD_ID_CHROMA_SUPPRESSION_CONFIG:
	case VFE_CMD_ID_CHROMA_SUPPRESSION_UPDATE: {
		struct vfe_cmd_chroma_suppression_config chromsup;
			CHECKED_COPY_FROM_USER(&chromsup);

		vfe_chroma_sup_config(&chromsup);
	}
		break;

	case VFE_CMD_ID_ASF_CONFIG: {
		struct vfe_cmd_asf_config asf;
			CHECKED_COPY_FROM_USER(&asf);

		vfe_asf_config(&asf);
	}
		break;

	case VFE_CMD_ID_SCALER2Y_CONFIG:
	case VFE_CMD_ID_SCALER2Y_UPDATE: {
		struct vfe_cmd_scaler2_config ds2y;
			CHECKED_COPY_FROM_USER(&ds2y);

		vfe_scaler2y_config(&ds2y);
	}
		break;

	case VFE_CMD_ID_SCALER2CbCr_CONFIG:
	case VFE_CMD_ID_SCALER2CbCr_UPDATE: {
		struct vfe_cmd_scaler2_config ds2cbcr;
			CHECKED_COPY_FROM_USER(&ds2cbcr);

		vfe_scaler2cbcr_config(&ds2cbcr);
	}
		break;

	case VFE_CMD_ID_CHROMA_SUBSAMPLE_CONFIG: {
		struct vfe_cmd_chroma_subsample_config sub;
			CHECKED_COPY_FROM_USER(&sub);

		vfe_chroma_subsample_config(&sub);
	}
		break;

	case VFE_CMD_ID_FRAME_SKIP_CONFIG: {
		struct vfe_cmd_frame_skip_config fskip;
			CHECKED_COPY_FROM_USER(&fskip);

		vfe_frame_skip_config(&fskip);
	}
		break;

	case VFE_CMD_ID_OUTPUT_CLAMP_CONFIG: {
		struct vfe_cmd_output_clamp_config clamp;
			CHECKED_COPY_FROM_USER(&clamp);

		vfe_output_clamp_config(&clamp);
	}
		break;

	
	case VFE_CMD_ID_BLACK_LEVEL_UPDATE: {
		struct vfe_cmd_black_level_config blk;
			CHECKED_COPY_FROM_USER(&blk);

		vfe_black_level_update(&blk);
	}
		break;

	case VFE_CMD_ID_DEMUX_CHANNEL_GAIN_UPDATE: {
		struct vfe_cmd_demux_channel_gain_config dmu;
			CHECKED_COPY_FROM_USER(&dmu);

		vfe_demux_channel_gain_update(&dmu);
	}
		break;

	case VFE_CMD_ID_DEMOSAIC_BPC_UPDATE: {
		struct vfe_cmd_demosaic_bpc_update demo_bpc;
			CHECKED_COPY_FROM_USER(&demo_bpc);

		vfe_demosaic_bpc_update(&demo_bpc);
	}
		break;

	case VFE_CMD_ID_DEMOSAIC_ABF_UPDATE: {
		struct vfe_cmd_demosaic_abf_update demo_abf;
			CHECKED_COPY_FROM_USER(&demo_abf);

		vfe_demosaic_abf_update(&demo_abf);
	}
		break;

	case VFE_CMD_ID_LA_UPDATE: {
		struct vfe_cmd_la_config la;
			CHECKED_COPY_FROM_USER(&la);

		vfe_la_update(&la);
	}
		break;

	case VFE_CMD_ID_RGB_GAMMA_UPDATE: {
		struct vfe_cmd_rgb_gamma_config rgb;
			CHECKED_COPY_FROM_USER(&rgb);

		rc = vfe_rgb_gamma_update(&rgb);
	}
		break;

	case VFE_CMD_ID_ASF_UPDATE: {
		struct vfe_cmd_asf_update asf;
			CHECKED_COPY_FROM_USER(&asf);

		vfe_asf_update(&asf);
	}
		break;

	case VFE_CMD_ID_FRAME_SKIP_UPDATE: {
		struct vfe_cmd_frame_skip_update fskip;
			CHECKED_COPY_FROM_USER(&fskip);
			
			if (fskip.output2Pattern == 0xffffffff)
				update_axi_qos(MSM_AXI_QOS_RECORDING);
			 else if (fskip.output2Pattern == 0)
				update_axi_qos(MSM_AXI_QOS_PREVIEW);

		vfe_frame_skip_update(&fskip);
	}
		break;

	case VFE_CMD_ID_CAMIF_FRAME_UPDATE: {
		struct vfe_cmds_camif_frame fup;
			CHECKED_COPY_FROM_USER(&fup);

		vfe_camif_frame_update(&fup);
	}
		break;

	
	case VFE_CMD_ID_STATS_AUTOFOCUS_UPDATE: {
		struct vfe_cmd_stats_af_update afup;
			CHECKED_COPY_FROM_USER(&afup);

		vfe_stats_update_af(&afup);
	}
		break;

	case VFE_CMD_ID_STATS_WB_EXP_UPDATE: {
		struct vfe_cmd_stats_wb_exp_update wbexp;
			CHECKED_COPY_FROM_USER(&wbexp);

		vfe_stats_update_wb_exp(&wbexp);
	}
		break;

	
	case VFE_CMD_ID_STOP:
		vfe_stop();
		break;

	case VFE_CMD_ID_GET_HW_VERSION:
		break;

	
	case VFE_CMD_ID_STATS_SETTING: {
		struct vfe_cmd_stats_setting stats;
			CHECKED_COPY_FROM_USER(&stats);

		vfe_stats_setting(&stats);
	}
		break;

	case VFE_CMD_ID_STATS_AUTOFOCUS_START: {
		struct vfe_cmd_stats_af_start af;
			CHECKED_COPY_FROM_USER(&af);

		vfe_stats_start_af(&af);
	}
		break;

	case VFE_CMD_ID_STATS_AUTOFOCUS_STOP:
		vfe_stats_af_stop();
		break;

	case VFE_CMD_ID_STATS_WB_EXP_START: {
		struct vfe_cmd_stats_wb_exp_start awexp;
			CHECKED_COPY_FROM_USER(&awexp);

		vfe_stats_start_wb_exp(&awexp);
	}
		break;

	case VFE_CMD_ID_STATS_WB_EXP_STOP:
		vfe_stats_wb_exp_stop();
		break;

	case VFE_CMD_ID_ASYNC_TIMER_SETTING:
		break;

	case VFE_CMD_ID_UPDATE:
		vfe_update();
		break;

	
	case VFE_CMD_ID_TEST_GEN_START:
		break;



	default:
		pr_err("%s: invalid cmd id %d\n", __func__, cmd->id);
		rc = -EINVAL;
		break;
	} 

	return rc;
}
Ejemplo n.º 3
0
static int vfe_proc_general(struct msm_vfe_command_8k *cmd)
{
	int rc = 0;

	CDBG("%s: cmdID = %d\n", __func__, cmd->id);

	switch (cmd->id) {
	case VFE_CMD_ID_RESET:
		msm_camio_vfe_blk_reset();
		msm_camio_camif_pad_reg_reset_2();
		vfe_reset();
		break;

	case VFE_CMD_ID_START:{
			struct vfe_cmd_start start;
			CHECKED_COPY_FROM_USER(&start);

			/* msm_camio_camif_pad_reg_reset_2(); */
			msm_camio_camif_pad_reg_reset();
			vfe_start(&start);
		}
		break;

	case VFE_CMD_ID_CAMIF_CONFIG:{
			struct vfe_cmd_camif_config camif;
			CHECKED_COPY_FROM_USER(&camif);

			vfe_camif_config(&camif);
		}
		break;

	case VFE_CMD_ID_BLACK_LEVEL_CONFIG:{
			struct vfe_cmd_black_level_config bl;
			CHECKED_COPY_FROM_USER(&bl);

			vfe_black_level_config(&bl);
		}
		break;

	case VFE_CMD_ID_ROLL_OFF_CONFIG:{
			/* rolloff is too big to be on the stack */
			struct vfe_cmd_roll_off_config *rolloff =
			    kmalloc(sizeof(struct vfe_cmd_roll_off_config),
				    GFP_KERNEL);
			if (!rolloff) {
				pr_err("%s: out of memory\n", __func__);
				rc = -ENOMEM;
				break;
			}
			/* Wrap CHECKED_COPY_FROM_USER() in a do-while(0) loop
			 * to make sure we free rolloff when copy_from_user()
			 * fails.
			 */
			do {
				CHECKED_COPY_FROM_USER(rolloff);
				vfe_roll_off_config(rolloff);
			} while (0);
			kfree(rolloff);
		}
		break;

	case VFE_CMD_ID_DEMUX_CHANNEL_GAIN_CONFIG:{
			struct vfe_cmd_demux_channel_gain_config demuxc;
			CHECKED_COPY_FROM_USER(&demuxc);

			/* demux is always enabled.  */
			vfe_demux_channel_gain_config(&demuxc);
		}
		break;

	case VFE_CMD_ID_DEMOSAIC_CONFIG:{
			struct vfe_cmd_demosaic_config demosaic;
			CHECKED_COPY_FROM_USER(&demosaic);

			vfe_demosaic_config(&demosaic);
		}
		break;

	case VFE_CMD_ID_FOV_CROP_CONFIG:
	case VFE_CMD_ID_FOV_CROP_UPDATE:{
			struct vfe_cmd_fov_crop_config fov;
			CHECKED_COPY_FROM_USER(&fov);

			vfe_fov_crop_config(&fov);
		}
		break;

	case VFE_CMD_ID_MAIN_SCALER_CONFIG:
	case VFE_CMD_ID_MAIN_SCALER_UPDATE:{
			struct vfe_cmd_main_scaler_config mainds;
			CHECKED_COPY_FROM_USER(&mainds);

			vfe_main_scaler_config(&mainds);
		}
		break;

	case VFE_CMD_ID_WHITE_BALANCE_CONFIG:
	case VFE_CMD_ID_WHITE_BALANCE_UPDATE:{
			struct vfe_cmd_white_balance_config wb;
			CHECKED_COPY_FROM_USER(&wb);

			vfe_white_balance_config(&wb);
		}
		break;

	case VFE_CMD_ID_COLOR_CORRECTION_CONFIG:
	case VFE_CMD_ID_COLOR_CORRECTION_UPDATE:{
			struct vfe_cmd_color_correction_config cc;
			CHECKED_COPY_FROM_USER(&cc);

			vfe_color_correction_config(&cc);
		}
		break;

	case VFE_CMD_ID_LA_CONFIG:{
			struct vfe_cmd_la_config la;
			CHECKED_COPY_FROM_USER(&la);

			vfe_la_config(&la);
		}
		break;

	case VFE_CMD_ID_RGB_GAMMA_CONFIG:{
			struct vfe_cmd_rgb_gamma_config rgb;
			CHECKED_COPY_FROM_USER(&rgb);

			rc = vfe_rgb_gamma_config(&rgb);
		}
		break;

	case VFE_CMD_ID_CHROMA_ENHAN_CONFIG:
	case VFE_CMD_ID_CHROMA_ENHAN_UPDATE:{
			struct vfe_cmd_chroma_enhan_config chrom;
			CHECKED_COPY_FROM_USER(&chrom);

			vfe_chroma_enhan_config(&chrom);
		}
		break;

	case VFE_CMD_ID_CHROMA_SUPPRESSION_CONFIG:
	case VFE_CMD_ID_CHROMA_SUPPRESSION_UPDATE:{
			struct vfe_cmd_chroma_suppression_config chromsup;
			CHECKED_COPY_FROM_USER(&chromsup);

			vfe_chroma_sup_config(&chromsup);
		}
		break;

	case VFE_CMD_ID_ASF_CONFIG:{
			struct vfe_cmd_asf_config asf;
			CHECKED_COPY_FROM_USER(&asf);

			vfe_asf_config(&asf);
		}
		break;

	case VFE_CMD_ID_SCALER2Y_CONFIG:
	case VFE_CMD_ID_SCALER2Y_UPDATE:{
			struct vfe_cmd_scaler2_config ds2y;
			CHECKED_COPY_FROM_USER(&ds2y);

			vfe_scaler2y_config(&ds2y);
		}
		break;

	case VFE_CMD_ID_SCALER2CbCr_CONFIG:
	case VFE_CMD_ID_SCALER2CbCr_UPDATE:{
			struct vfe_cmd_scaler2_config ds2cbcr;
			CHECKED_COPY_FROM_USER(&ds2cbcr);

			vfe_scaler2cbcr_config(&ds2cbcr);
		}
		break;

	case VFE_CMD_ID_CHROMA_SUBSAMPLE_CONFIG:{
			struct vfe_cmd_chroma_subsample_config sub;
			CHECKED_COPY_FROM_USER(&sub);

			vfe_chroma_subsample_config(&sub);
		}
		break;

	case VFE_CMD_ID_FRAME_SKIP_CONFIG:{
			struct vfe_cmd_frame_skip_config fskip;
			CHECKED_COPY_FROM_USER(&fskip);

			vfe_frame_skip_config(&fskip);
		}
		break;

	case VFE_CMD_ID_OUTPUT_CLAMP_CONFIG:{
			struct vfe_cmd_output_clamp_config clamp;
			CHECKED_COPY_FROM_USER(&clamp);

			vfe_output_clamp_config(&clamp);
		}
		break;

		/* module update commands */
	case VFE_CMD_ID_BLACK_LEVEL_UPDATE:{
			struct vfe_cmd_black_level_config blk;
			CHECKED_COPY_FROM_USER(&blk);

			vfe_black_level_update(&blk);
		}
		break;

	case VFE_CMD_ID_DEMUX_CHANNEL_GAIN_UPDATE:{
			struct vfe_cmd_demux_channel_gain_config dmu;
			CHECKED_COPY_FROM_USER(&dmu);

			vfe_demux_channel_gain_update(&dmu);
		}
		break;

	case VFE_CMD_ID_DEMOSAIC_BPC_UPDATE:{
			struct vfe_cmd_demosaic_bpc_update demo_bpc;
			CHECKED_COPY_FROM_USER(&demo_bpc);

			vfe_demosaic_bpc_update(&demo_bpc);
		}
		break;

	case VFE_CMD_ID_DEMOSAIC_ABF_UPDATE:{
			struct vfe_cmd_demosaic_abf_update demo_abf;
			CHECKED_COPY_FROM_USER(&demo_abf);

			vfe_demosaic_abf_update(&demo_abf);
		}
		break;

	case VFE_CMD_ID_LA_UPDATE:{
			struct vfe_cmd_la_config la;
			CHECKED_COPY_FROM_USER(&la);

			vfe_la_update(&la);
		}
		break;

	case VFE_CMD_ID_RGB_GAMMA_UPDATE:{
			struct vfe_cmd_rgb_gamma_config rgb;
			CHECKED_COPY_FROM_USER(&rgb);

			rc = vfe_rgb_gamma_update(&rgb);
		}
		break;

	case VFE_CMD_ID_ASF_UPDATE:{
			struct vfe_cmd_asf_update asf;
			CHECKED_COPY_FROM_USER(&asf);

			vfe_asf_update(&asf);
		}
		break;

	case VFE_CMD_ID_FRAME_SKIP_UPDATE:{
			struct vfe_cmd_frame_skip_update fskip;
			CHECKED_COPY_FROM_USER(&fskip);

			vfe_frame_skip_update(&fskip);
		}
		break;

	case VFE_CMD_ID_CAMIF_FRAME_UPDATE:{
			struct vfe_cmds_camif_frame fup;
			CHECKED_COPY_FROM_USER(&fup);

			vfe_camif_frame_update(&fup);
		}
		break;

		/* stats update commands */
	case VFE_CMD_ID_STATS_AUTOFOCUS_UPDATE:{
			struct vfe_cmd_stats_af_update afup;
			CHECKED_COPY_FROM_USER(&afup);

			vfe_stats_update_af(&afup);
		}
		break;

	case VFE_CMD_ID_STATS_WB_EXP_UPDATE:{
			struct vfe_cmd_stats_wb_exp_update wbexp;
			CHECKED_COPY_FROM_USER(&wbexp);

			vfe_stats_update_wb_exp(&wbexp);
		}
		break;

		/* control of start, stop, update, etc... */
	case VFE_CMD_ID_STOP:
		vfe_stop();
		break;

	case VFE_CMD_ID_GET_HW_VERSION:
		break;

		/* stats */
	case VFE_CMD_ID_STATS_SETTING:{
			struct vfe_cmd_stats_setting stats;
			CHECKED_COPY_FROM_USER(&stats);

			vfe_stats_setting(&stats);
		}
		break;

	case VFE_CMD_ID_STATS_AUTOFOCUS_START:{
			struct vfe_cmd_stats_af_start af;
			CHECKED_COPY_FROM_USER(&af);

			vfe_stats_start_af(&af);
		}
		break;

	case VFE_CMD_ID_STATS_AUTOFOCUS_STOP:
		vfe_stats_af_stop();
		break;

	case VFE_CMD_ID_STATS_WB_EXP_START:{
			struct vfe_cmd_stats_wb_exp_start awexp;
			CHECKED_COPY_FROM_USER(&awexp);

			vfe_stats_start_wb_exp(&awexp);
		}
		break;

	case VFE_CMD_ID_STATS_WB_EXP_STOP:
		vfe_stats_wb_exp_stop();
		break;

	case VFE_CMD_ID_ASYNC_TIMER_SETTING:
		break;

	case VFE_CMD_ID_UPDATE:
		vfe_update();
		break;

		/* test gen */
	case VFE_CMD_ID_TEST_GEN_START:
		break;

	case VFE_CMD_ID_EPOCH1_CONFIG:{
			struct vfe_cmds_camif_epoch epoch1;
			CHECKED_COPY_FROM_USER(&epoch1);
			vfe_epoch1_config(&epoch1);
		}
		break;

/*
  acknowledge from upper layer
	these are not in general command.

	case VFE_CMD_ID_OUTPUT1_ACK:
		break;
	case VFE_CMD_ID_OUTPUT2_ACK:
		break;
	case VFE_CMD_ID_EPOCH1_ACK:
		break;
	case VFE_CMD_ID_EPOCH2_ACK:
		break;
	case VFE_CMD_ID_STATS_AUTOFOCUS_ACK:
		break;
	case VFE_CMD_ID_STATS_WB_EXP_ACK:
		break;
*/

	default:
		pr_err("%s: invalid cmd id %d\n", __func__, cmd->id);
		rc = -EINVAL;
		break;
	}			/* switch */

	return rc;
}
Ejemplo n.º 4
0
static int vfe_7x_config(struct msm_vfe_cfg_cmd_t *cmd, void *data)
{
	struct msm_pmem_region *regptr;
	unsigned char buf[256];

	struct vfe_stats_ack_t sack;
	struct axidata_t *axid;
	uint32_t i;

	struct vfe_stats_we_cfg_t *scfg_t = NULL;
	struct vfe_stats_af_cfg_t *sfcfg_t = NULL;
	struct axiout_t *axio = NULL;
	void   *cmd_data = NULL;
	void   *cmd_data_alloc = NULL;
	long rc = 0;
	struct msm_vfe_command_7k *vfecmd;

	vfecmd = kmalloc(sizeof(struct msm_vfe_command_7k),
				GFP_ATOMIC);
	if (!vfecmd) {
		CDBG_ERR("vfe_7x_config:vfecmd kmalloc fail\n");
		return -ENOMEM;
	}

	if (cmd->cmd_type != CMD_FRAME_BUF_RELEASE &&
	    cmd->cmd_type != CMD_STATS_BUF_RELEASE &&
	    cmd->cmd_type != CMD_STATS_AF_BUF_RELEASE) {
		if (copy_from_user(vfecmd,
				(void __user *)(cmd->value),
				sizeof(struct msm_vfe_command_7k))) {
			CDBG_ERR("vfe_7x_config:copy 0x%p ->0x%p fail LINE:%d\n",
				vfecmd->value,vfecmd,__LINE__);
			rc = -EFAULT;
			goto config_failure;
		}
	}

	switch (cmd->cmd_type) {
	case CMD_STATS_ENABLE:
	case CMD_STATS_AXI_CFG: {
		axid = data;
		if (!axid) {
			CDBG_ERR("vfe_7x_config:axid NULL pointer LINE:%d\n",__LINE__);
			rc = -EFAULT;
			goto config_failure;
		}

		scfg_t = kmalloc(sizeof(struct vfe_stats_we_cfg_t),
				GFP_ATOMIC);
		if (!scfg_t) {
			CDBG_ERR("vfe_7x_config:scfg_t kmalloc fail\n");
			rc = -ENOMEM;
			goto config_failure;
		}

		if (copy_from_user(scfg_t,
					(void __user *)(vfecmd->value),
					vfecmd->length)) {
			CDBG_ERR("vfe_7x_config:copy 0x%p ->0x%p fail LINE:%d\n",
				vfecmd->value,scfg_t,__LINE__);
			rc = -EFAULT;
			goto config_done;
		}

		CDBG("STATS_ENABLE: bufnum = %d, enabling = %d\n",
			axid->bufnum1, scfg_t->wb_expstatsenable);

		if (axid->bufnum1 > 0) {
			regptr = axid->region;

			for (i = 0; i < axid->bufnum1; i++) {

				CDBG("STATS_ENABLE, phy = 0x%lx\n",
					regptr->paddr);

				scfg_t->wb_expstatoutputbuffer[i] =
					(void *)regptr->paddr;
				regptr++;
			}

			cmd_data = scfg_t;

		} else {
			CDBG_ERR("vfe_7x_config:axid->bufnum1:%d\n",axid->bufnum1);
			rc = -EINVAL;
			goto config_done;
		}
		}
		break;

	case CMD_STATS_AF_ENABLE:
	case CMD_STATS_AF_AXI_CFG: {
		axid = data;
		if (!axid) {
			CDBG_ERR("vfe_7x_config:axid NULL pointer LINE:%d\n",__LINE__);
			rc = -EFAULT;
			goto config_failure;
		}

		sfcfg_t = kmalloc(sizeof(struct vfe_stats_af_cfg_t),
				GFP_ATOMIC);

		if (!sfcfg_t) {
			CDBG_ERR("vfe_7x_config:sfcfg_t kmalloc fail\n");
			rc = -ENOMEM;
			goto config_failure;
		}

		if (copy_from_user(sfcfg_t,
					(void __user *)(vfecmd->value),
					vfecmd->length)) {
			CDBG_ERR("vfe_7x_config:copy 0x%p ->0x%p fail LINE:%d\n",
				vfecmd->value,sfcfg_t,__LINE__);
			rc = -EFAULT;
			goto config_done;
		}

		CDBG("AF_ENABLE: bufnum = %d, enabling = %d\n",
			axid->bufnum1, sfcfg_t->af_enable);

		if (axid->bufnum1 > 0) {
			regptr = axid->region;

			for (i = 0; i < axid->bufnum1; i++) {

				CDBG("STATS_ENABLE, phy = 0x%lx\n",
					regptr->paddr);

				sfcfg_t->af_outbuf[i] =
					(void *)regptr->paddr;

				regptr++;
			}

			cmd_data = sfcfg_t;

		} else {
			CDBG_ERR("vfe_7x_config:axid->bufnum1:%d\n",axid->bufnum1);
			rc = -EINVAL;
			goto config_done;
		}
		}
		break;

	case CMD_FRAME_BUF_RELEASE: {
		struct msm_frame_t *b;
		unsigned long p;
		struct vfe_outputack_t fack;
		if (!data)  {
			CDBG_ERR("vfe_7x_config:data NULL pointer LINE:%d\n",__LINE__);
			rc = -EFAULT;
			goto config_failure;
		}

		b = (struct msm_frame_t *)(cmd->value);
		p = *(unsigned long *)data;

		fack.header = VFE_FRAME_ACK;

		fack.output2newybufferaddress =
			(void *)(p + b->y_off);

		fack.output2newcbcrbufferaddress =
			(void *)(p + b->cbcr_off);

		vfecmd->queue = QDSP_CMDQUEUE;
		vfecmd->length = sizeof(struct vfe_outputack_t);
		cmd_data = &fack;
	}
		break;

	case CMD_SNAP_BUF_RELEASE:
		break;

	case CMD_STATS_BUF_RELEASE: {
    		CDBG("vfe_7x_config: CMD_STATS_BUF_RELEASE\n");
		if (!data) {
			rc = -EFAULT;
			goto config_failure;
		}

		sack.header = STATS_WE_ACK;
		sack.bufaddr = (void *)*(uint32_t *)data;

		vfecmd->queue  = QDSP_CMDQUEUE;
		vfecmd->length = sizeof(struct vfe_stats_ack_t);
		cmd_data = &sack;
		}
		break;

	case CMD_STATS_AF_BUF_RELEASE: {
    		CDBG("vfe_7x_config: CMD_STATS_AF_BUF_RELEASE\n");
    		if (!data) {
			rc = -EFAULT;
			goto config_failure;
		}

		sack.header = STATS_AF_ACK;
		sack.bufaddr = (void *)*(uint32_t *)data;

		vfecmd->queue  = QDSP_CMDQUEUE;
		vfecmd->length = sizeof(struct vfe_stats_ack_t);
		cmd_data = &sack;
		}
		break;

	case CMD_GENERAL:
	case CMD_STATS_DISABLE: {
		if (vfecmd->length > 256) {
			cmd_data_alloc =
			cmd_data = kmalloc(vfecmd->length, GFP_ATOMIC);
			if (!cmd_data) {
				CDBG_ERR("vfe_7x_config:cmd_data kmalloc fail\n");
				rc = -ENOMEM;
				goto config_failure;
			}
		} else
			cmd_data = buf;

		if (copy_from_user(cmd_data,
					(void __user *)(vfecmd->value),
					vfecmd->length)) {
			CDBG_ERR("vfe_7x_config:copy 0x%p ->0x%p fail LINE:%d\n",
				vfecmd->value,cmd_data,__LINE__);
			rc = -EFAULT;
			goto config_done;
		}

		if (vfecmd->queue == QDSP_CMDQUEUE) {
			switch (*(uint32_t *)cmd_data) {
			case VFE_RESET_CMD:
				msm_camio_vfe_blk_reset();
				msm_camio_camif_pad_reg_reset_2();
				vfestopped = 0;
				CDBG("%s, VFE_RESET_CMD, vfestopped = %d\n", __func__  , vfestopped);
				break;

			case VFE_START_CMD:
				msm_camio_camif_pad_reg_reset_2();
				vfestopped = 0;
				CDBG("%s, VFE_START_CMD, vfestopped = %d\n", __func__  , vfestopped);
				break;

			case VFE_STOP_CMD:
				vfestopped = 1;
				CDBG("%s, VFE_STOP_CMD, vfestopped = %d\n", __func__  , vfestopped);
				goto config_send;
			default:
				break;
			}
		} /* QDSP_CMDQUEUE */
		}
		break;

	case CMD_AXI_CFG_OUT1: {
		axid = data;
		if (!axid) {
			CDBG_ERR("vfe_7x_config:axid NULL pointer LINE:%d\n",__LINE__);
			rc = -EFAULT;
			goto config_failure;
		}

		axio = kmalloc(sizeof(struct axiout_t), GFP_ATOMIC);
		if (!axio) {
			CDBG_ERR("vfe_7x_config:axio kmalloc fail\n");
			rc = -ENOMEM;
			goto config_failure;
		}

		if (copy_from_user(axio, (void *)(vfecmd->value),
					sizeof(struct axiout_t))) {
			CDBG_ERR("vfe_7x_config:copy 0x%p ->0x%p fail LINE:%d\n",
				vfecmd->value,axio,__LINE__);
			rc = -EFAULT;
			goto config_done;
		}

		vfe_7x_config_axi(OUTPUT_1, axid, axio);

		cmd_data = axio;
	}
		break;

	case CMD_AXI_CFG_OUT2:
	case CMD_RAW_PICT_AXI_CFG: {
		axid = data;
		if (!axid) {
			CDBG_ERR("vfe_7x_config:axid NULL pointer LINE:%d\n",__LINE__);
			rc = -EFAULT;
			goto config_failure;
		}

		axio = kmalloc(sizeof(struct axiout_t), GFP_ATOMIC);
		if (!axio) {
			CDBG_ERR("vfe_7x_config:axio kmalloc fail\n");
			rc = -ENOMEM;
			goto config_failure;
		}

		if (copy_from_user(axio, (void __user *)(vfecmd->value),
					sizeof(struct axiout_t))) {
			CDBG_ERR("vfe_7x_config:copy 0x%p ->0x%p fail LINE:%d\n",
				vfecmd->value,axio,__LINE__);
			rc = -EFAULT;
			goto config_done;
		}

		vfe_7x_config_axi(OUTPUT_2, axid, axio);
		cmd_data = axio;
		}
		break;

	case CMD_AXI_CFG_SNAP_O1_AND_O2: {
		axid = data;
		if (!axid) {
			CDBG_ERR("vfe_7x_config:axid NULL pointer LINE:%d\n",__LINE__);
			rc = -EFAULT;
			goto config_failure;
		}

		axio = kmalloc(sizeof(struct axiout_t), GFP_ATOMIC);
		if (!axio) {
			CDBG_ERR("vfe_7x_config:axio kmalloc fail\n");
			rc = -ENOMEM;
			goto config_failure;
		}

		if (copy_from_user(axio, (void __user *)(vfecmd->value),
					sizeof(struct axiout_t))) {
			CDBG_ERR("vfe_7x_config:copy 0x%p ->0x%p fail LINE:%d\n",
				vfecmd->value,axio,__LINE__);
			rc = -EFAULT;
			goto config_done;
		}

		vfe_7x_config_axi(OUTPUT_1_AND_2, axid, axio);
               CDBG("cmdheader = %d\n", axio->cmdheader);
               CDBG("outputmode = %d\n", axio->outputmode);
               CDBG("format = %d\n", axio->format);
               CDBG("out2yimageheight = %d\n", axio->out2yimageheight);
               CDBG("out2yimagewidthin64bitwords = %d\n", axio->out2yimagewidthin64bitwords);
               CDBG("out2yburstlen = %d\n", axio->out2yburstlen);
               CDBG("out2ynumrows = %d\n", axio->out2ynumrows);
               CDBG("out2yrowincin64bitincs = %d\n", axio->out2yrowincin64bitincs);
               CDBG("out2cbcrimageheight = %d\n", axio->out2cbcrimageheight);
               CDBG("out2cbcrimagewidtein64bitwords = %d\n", axio->out2cbcrimagewidtein64bitwords);
               CDBG("out2cbcrburstlen = %d\n", axio->out2cbcrburstlen);
               CDBG("out2cbcrnumrows = %d\n", axio->out2cbcrnumrows);
               CDBG("out2cbcrrowincin64bitincs = %d\n", axio->out2cbcrrowincin64bitincs);
               CDBG("output2buffer1_y_phy = %ld\n", axio->output2buffer1_y_phy);
               CDBG("output2buffer1_cbcr_phy = %ld\n", axio->output2buffer1_cbcr_phy);
               CDBG("output2buffer2_y_phy = %ld\n", axio->output2buffer2_y_phy);
               CDBG("output2buffer2_cbcr_phy = %ld\n", axio->output2buffer2_cbcr_phy);
               CDBG("output2buffer3_y_phy = %ld\n", axio->output2buffer3_y_phy);
               CDBG("output2buffer3_cbcr_phy = %ld\n", axio->output2buffer3_cbcr_phy);
               CDBG("output2buffer4_y_phy = %ld\n", axio->output2buffer4_y_phy);
               CDBG("output2buffer4_cbcr_phy = %ld\n", axio->output2buffer4_cbcr_phy);
               CDBG("output2buffer5_y_phy = %ld\n", axio->output2buffer5_y_phy);
		CDBG("output2buffer5_cbcr_phy = %ld\n", axio->output2buffer5_cbcr_phy);

		cmd_data = axio;
	}
		break;

	default:
		break;
	} /* switch */

	if (vfestopped)
		goto config_done;

config_send:
	CDBG("send adsp command = %d\n", *(uint32_t *)cmd_data);
	rc = msm_adsp_write(vfe_mod, vfecmd->queue,
				cmd_data, vfecmd->length);

config_done:
	if (cmd_data_alloc != NULL)
		kfree(cmd_data_alloc);

config_failure:
	kfree(scfg_t);
	kfree(sfcfg_t);
	kfree(axio);
	kfree(vfecmd);
	return rc;
}