Пример #1
0
static void mdp_calc_scaleInitPhase_3p1(uint32 in_w,
                                        uint32 in_h,
                                        uint32 out_w,
                                        uint32 out_h,
                                        boolean is_rotate,
                                        boolean is_pp_x,
                                        boolean is_pp_y, struct phase_val *pval)
{
    uint64 dst_ROI_width;
    uint64 dst_ROI_height;
    uint64 src_ROI_width;
    uint64 src_ROI_height;

    /*
     * phase_step_x, phase_step_y, phase_init_x and phase_init_y
     * are represented in fixed-point, unsigned 3.29 format
     */
    uint32 phase_step_x = 0;
    uint32 phase_step_y = 0;
    uint32 phase_init_x = 0;
    uint32 phase_init_y = 0;
    uint32 yscale_filter_sel, xscale_filter_sel;
    uint32 scale_unit_sel_x, scale_unit_sel_y;

    uint64 numerator, denominator;
    uint64 temp_dim;

    src_ROI_width = in_w;
    src_ROI_height = in_h;
    dst_ROI_width = out_w;
    dst_ROI_height = out_h;

    /* if there is a 90 degree rotation */
    if (is_rotate) {
        /* decide whether to use FIR or M/N for scaling */

        /* if down-scaling by a factor smaller than 1/4 */
        if ((dst_ROI_height == 1 && src_ROI_width < 4) ||
                (src_ROI_width < 4 * dst_ROI_height - 3))
            scale_unit_sel_x = 0;/* use FIR scalar */
        else
            scale_unit_sel_x = 1;/* use M/N scalar */

        /* if down-scaling by a factor smaller than 1/4 */
        if ((dst_ROI_width == 1 && src_ROI_height < 4) ||
                (src_ROI_height < 4 * dst_ROI_width - 3))
            scale_unit_sel_y = 0;/* use FIR scalar */
        else
            scale_unit_sel_y = 1;/* use M/N scalar */
    } else {
        /* decide whether to use FIR or M/N for scaling */
        if ((dst_ROI_width == 1 && src_ROI_width < 4) ||
                (src_ROI_width < 4 * dst_ROI_width - 3))
            scale_unit_sel_x = 0;/* use FIR scalar */
        else
            scale_unit_sel_x = 1;/* use M/N scalar */

        if ((dst_ROI_height == 1 && src_ROI_height < 4) ||
                (src_ROI_height < 4 * dst_ROI_height - 3))
            scale_unit_sel_y = 0;/* use FIR scalar */
        else
            scale_unit_sel_y = 1;/* use M/N scalar */
    }

    /* if there is a 90 degree rotation */
    if (is_rotate) {
        /* swap the width and height of dst ROI */
        temp_dim = dst_ROI_width;
        dst_ROI_width = dst_ROI_height;
        dst_ROI_height = temp_dim;
    }

    /* calculate phase step for the x direction */

    /* if destination is only 1 pixel wide, the value of phase_step_x
       is unimportant. Assigning phase_step_x to src ROI width
       as an arbitrary value. */
    if (dst_ROI_width == 1)
        phase_step_x = (uint32) ((src_ROI_width) << SCALER_PHASE_BITS);

    /* if using FIR scalar */
    else if (scale_unit_sel_x == 0) {

        /* Calculate the quotient ( src_ROI_width - 1 ) / ( dst_ROI_width - 1)
           with u3.29 precision. Quotient is rounded up to the larger
           29th decimal point. */
        numerator = (src_ROI_width - 1) << SCALER_PHASE_BITS;
        denominator = (dst_ROI_width - 1);	/* never equals to 0 because of the "( dst_ROI_width == 1 ) case" */
        phase_step_x = (uint32) mdp_do_div((numerator + denominator - 1), denominator);	/* divide and round up to the larger 29th decimal point. */

    }

    /* if M/N scalar */
    else if (scale_unit_sel_x == 1) {
        /* Calculate the quotient ( src_ROI_width ) / ( dst_ROI_width)
           with u3.29 precision. Quotient is rounded down to the
           smaller 29th decimal point. */
        numerator = (src_ROI_width) << SCALER_PHASE_BITS;
        denominator = (dst_ROI_width);
        phase_step_x = (uint32) mdp_do_div(numerator, denominator);
    }
    /* calculate phase step for the y direction */

    /* if destination is only 1 pixel wide, the value of
       phase_step_x is unimportant. Assigning phase_step_x
       to src ROI width as an arbitrary value. */
    if (dst_ROI_height == 1)
        phase_step_y = (uint32) ((src_ROI_height) << SCALER_PHASE_BITS);

    /* if FIR scalar */
    else if (scale_unit_sel_y == 0) {
        /* Calculate the quotient ( src_ROI_height - 1 ) / ( dst_ROI_height - 1)
           with u3.29 precision. Quotient is rounded up to the larger
           29th decimal point. */
        numerator = (src_ROI_height - 1) << SCALER_PHASE_BITS;
        denominator = (dst_ROI_height - 1);	/* never equals to 0 because of the "( dst_ROI_height == 1 )" case */
        phase_step_y = (uint32) mdp_do_div((numerator + denominator - 1), denominator);	/* Quotient is rounded up to the larger 29th decimal point. */

    }

    /* if M/N scalar */
    else if (scale_unit_sel_y == 1) {
        /* Calculate the quotient ( src_ROI_height ) / ( dst_ROI_height)
           with u3.29 precision. Quotient is rounded down to the smaller
           29th decimal point. */
        numerator = (src_ROI_height) << SCALER_PHASE_BITS;
        denominator = (dst_ROI_height);
        phase_step_y = (uint32) mdp_do_div(numerator, denominator);
    }

    /* decide which set of FIR coefficients to use */
    if (phase_step_x > HAL_MDP_PHASE_STEP_2P50)
        xscale_filter_sel = 0;
    else if (phase_step_x > HAL_MDP_PHASE_STEP_1P66)
        xscale_filter_sel = 1;
    else if (phase_step_x > HAL_MDP_PHASE_STEP_1P25)
        xscale_filter_sel = 2;
    else
        xscale_filter_sel = 3;

    if (phase_step_y > HAL_MDP_PHASE_STEP_2P50)
        yscale_filter_sel = 0;
    else if (phase_step_y > HAL_MDP_PHASE_STEP_1P66)
        yscale_filter_sel = 1;
    else if (phase_step_y > HAL_MDP_PHASE_STEP_1P25)
        yscale_filter_sel = 2;
    else
        yscale_filter_sel = 3;

    /* calculate phase init for the x direction */

    /* if using FIR scalar */
    if (scale_unit_sel_x == 0) {
        if (dst_ROI_width == 1)
            phase_init_x =
                (uint32) ((src_ROI_width - 1) << SCALER_PHASE_BITS);
        else
            phase_init_x = 0;

    }
    /* M over N scalar  */
    else if (scale_unit_sel_x == 1)
        phase_init_x = 0;

    /* calculate phase init for the y direction
       if using FIR scalar */
    if (scale_unit_sel_y == 0) {
        if (dst_ROI_height == 1)
            phase_init_y =
                (uint32) ((src_ROI_height -
                           1) << SCALER_PHASE_BITS);
        else
            phase_init_y = 0;

    }
    /* M over N scalar   */
    else if (scale_unit_sel_y == 1)
        phase_init_y = 0;

    /* write registers */
    pval->phase_step_x = (uint32) phase_step_x;
    pval->phase_step_y = (uint32) phase_step_y;
    pval->phase_init_x = (uint32) phase_init_x;
    pval->phase_init_y = (uint32) phase_init_y;

    return;
}
Пример #2
0
static void mdp_calc_scaleInitPhase_3p1(uint32 in_w,
					uint32 in_h,
					uint32 out_w,
					uint32 out_h,
					boolean is_rotate,
					boolean is_pp_x,
					boolean is_pp_y, struct phase_val *pval)
{
	uint64 dst_ROI_width;
	uint64 dst_ROI_height;
	uint64 src_ROI_width;
	uint64 src_ROI_height;

	/*
                                                             
                                                        
  */
	uint32 phase_step_x = 0;
	uint32 phase_step_y = 0;
	uint32 phase_init_x = 0;
	uint32 phase_init_y = 0;
	uint32 yscale_filter_sel, xscale_filter_sel;
	uint32 scale_unit_sel_x, scale_unit_sel_y;

	uint64 numerator, denominator;
	uint64 temp_dim;

	src_ROI_width = in_w;
	src_ROI_height = in_h;
	dst_ROI_width = out_w;
	dst_ROI_height = out_h;

	/*                                  */
	if (is_rotate) {
		/*                                              */

		/*                                              */
		if ((dst_ROI_height == 1 && src_ROI_width < 4) ||
			(src_ROI_width < 4 * dst_ROI_height - 3))
			scale_unit_sel_x = 0;/*                */
		else
			scale_unit_sel_x = 1;/*                */

		/*                                              */
		if ((dst_ROI_width == 1 && src_ROI_height < 4) ||
			(src_ROI_height < 4 * dst_ROI_width - 3))
			scale_unit_sel_y = 0;/*                */
		else
			scale_unit_sel_y = 1;/*                */
	} else {
		/*                                              */
		if ((dst_ROI_width == 1 && src_ROI_width < 4) ||
			(src_ROI_width < 4 * dst_ROI_width - 3))
			scale_unit_sel_x = 0;/*                */
		else
			scale_unit_sel_x = 1;/*                */

		if ((dst_ROI_height == 1 && src_ROI_height < 4) ||
			(src_ROI_height < 4 * dst_ROI_height - 3))
			scale_unit_sel_y = 0;/*                */
		else
			scale_unit_sel_y = 1;/*                */
	}

	/*                                  */
	if (is_rotate) {
		/*                                      */
		temp_dim = dst_ROI_width;
		dst_ROI_width = dst_ROI_height;
		dst_ROI_height = temp_dim;
	}

	/*                                          */

	/*                                                               
                                                           
                           */
	if (dst_ROI_width == 1)
		phase_step_x = (uint32) ((src_ROI_width) << SCALER_PHASE_BITS);

	/*                     */
	else if (scale_unit_sel_x == 0) {

		/*                                                                    
                                                               
                         */
		numerator = (src_ROI_width - 1) << SCALER_PHASE_BITS;
		denominator = (dst_ROI_width - 1);	/*                                                                */
		phase_step_x = (uint32) mdp_do_div((numerator + denominator - 1), denominator);	/*                                                       */

	}

	/*               */
	else if (scale_unit_sel_x == 1) {
		/*                                                            
                                                          
                                 */
		numerator = (src_ROI_width) << SCALER_PHASE_BITS;
		denominator = (dst_ROI_width);
		phase_step_x = (uint32) mdp_do_div(numerator, denominator);
	}
	/*                                          */

	/*                                                  
                                                       
                                            */
	if (dst_ROI_height == 1)
		phase_step_y = (uint32) ((src_ROI_height) << SCALER_PHASE_BITS);

	/*               */
	else if (scale_unit_sel_y == 0) {
		/*                                                                      
                                                               
                         */
		numerator = (src_ROI_height - 1) << SCALER_PHASE_BITS;
		denominator = (dst_ROI_height - 1);	/*                                                                 */
		phase_step_y = (uint32) mdp_do_div((numerator + denominator - 1), denominator);	/*                                                          */

	}

	/*               */
	else if (scale_unit_sel_y == 1) {
		/*                                                              
                                                                  
                         */
		numerator = (src_ROI_height) << SCALER_PHASE_BITS;
		denominator = (dst_ROI_height);
		phase_step_y = (uint32) mdp_do_div(numerator, denominator);
	}

	/*                                             */
	if (phase_step_x > HAL_MDP_PHASE_STEP_2P50)
		xscale_filter_sel = 0;
	else if (phase_step_x > HAL_MDP_PHASE_STEP_1P66)
		xscale_filter_sel = 1;
	else if (phase_step_x > HAL_MDP_PHASE_STEP_1P25)
		xscale_filter_sel = 2;
	else
		xscale_filter_sel = 3;

	if (phase_step_y > HAL_MDP_PHASE_STEP_2P50)
		yscale_filter_sel = 0;
	else if (phase_step_y > HAL_MDP_PHASE_STEP_1P66)
		yscale_filter_sel = 1;
	else if (phase_step_y > HAL_MDP_PHASE_STEP_1P25)
		yscale_filter_sel = 2;
	else
		yscale_filter_sel = 3;

	/*                                          */

	/*                     */
	if (scale_unit_sel_x == 0) {
		if (dst_ROI_width == 1)
			phase_init_x =
			    (uint32) ((src_ROI_width - 1) << SCALER_PHASE_BITS);
		else
			phase_init_x = 0;

	}
	/*                  */
	else if (scale_unit_sel_x == 1)
		phase_init_x = 0;

	/*                                         
                        */
	if (scale_unit_sel_y == 0) {
		if (dst_ROI_height == 1)
			phase_init_y =
			    (uint32) ((src_ROI_height -
				       1) << SCALER_PHASE_BITS);
		else
			phase_init_y = 0;

	}
	/*                   */
	else if (scale_unit_sel_y == 1)
		phase_init_y = 0;

	/*                 */
	pval->phase_step_x = (uint32) phase_step_x;
	pval->phase_step_y = (uint32) phase_step_y;
	pval->phase_init_x = (uint32) phase_init_x;
	pval->phase_init_y = (uint32) phase_init_y;

	return;
}