Example #1
0
static int adv748x_afe_read_ro_map(struct adv748x_state *state, u8 reg)
{
	int ret;

	/* Select SDP Read-Only Main Map */
	ret = sdp_write(state, ADV748X_SDP_MAP_SEL,
			ADV748X_SDP_MAP_SEL_RO_MAIN);
	if (ret < 0)
		return ret;

	return sdp_read(state, reg);
}
Example #2
0
/**
 * Stop running program.
 * @param sdp   Pointer to sdp_t structure, initialized by sdp_open.
 * @return      On success 0, on error negative number (error no.).
 */
int sdp_stop(const sdp_t *sdp)
{
        char buf[SDP_BUF_SIZE_MIN];
        int ret;

        if ( (ret = sdp_sstop(buf, sdp->addr)) < 0)
                return ret;

        if ( (ret = sdp_write(sdp->f_out, buf, ret)) < 0)
                return ret;

        if ( (ret = sdp_read_resp(sdp->f_in, buf, SDP_RESP_LEN_OK)) < 0)
                return ret;

        return 0;
}
Example #3
0
/**
 * Set value of program item.
 * @param sdp   Pointer to sdp_t structure, initialized by sdp_open.
 * @param progn Number of program item to set.
 * @param program       New value of program item.
 * @return      On success 0, on error negative number (error no.).
 */
int sdp_set_program(const sdp_t *sdp, int progn, const sdp_program_t *program)
{
        char buf[SDP_BUF_SIZE_MIN];
        int ret;

        if ( (ret = sdp_sset_program(buf, sdp->addr, progn, program)) < 0)
                return ret;

        if ( (ret = sdp_write(sdp->f_out, buf, ret)) < 0)
                return ret;

        if ( (ret = sdp_read_resp(sdp->f_in, buf, SDP_RESP_LEN_OK)) < 0)
                return ret;

        return 0;
}
Example #4
0
/**
 * Set power on status of output for specific preset item.
 * @param sdp   Pointer to sdp_t structure, initialized by sdp_open.
 * @param presn Number of preset to set output state.
 * @param enable        When 0 output is disablen on power, otherwise enabled.
 * @return      On success 0, on error negative number (error no.).
 */
int sdp_set_poweron_output(const sdp_t *sdp, int presn, int enable)
{
        char buf[SDP_BUF_SIZE_MIN];
        int ret;

        if ( (ret = sdp_sset_poweron_output(buf, sdp->addr, presn, enable)) < 0)
                return ret;

        if ( (ret = sdp_write(sdp->f_out, buf, ret)) < 0)
                return ret;

        if ( (ret = sdp_read_resp(sdp->f_in, buf, SDP_RESP_LEN_OK)) < 0)
                return ret;

        return 0;
}
Example #5
0
/**
 * Set upper voltage limit.
 * @param sdp   Pointer to sdp_t structure, initialized by sdp_open.
 * @param volt  Wanted upper voltage limit: [V].
 * @return      On success 0, on error negative number (error no.).
 */
int sdp_set_volt_limit(const sdp_t *sdp, double volt)
{
        char buf[SDP_BUF_SIZE_MIN];
        int ret;

        if ( (ret = sdp_sset_volt_limit(buf, sdp->addr, volt)) < 0)
                return ret;

        if ( (ret = sdp_write(sdp->f_out, buf, ret)) < 0)
                return ret;

        if ( (ret = sdp_read_resp(sdp->f_in, buf, SDP_RESP_LEN_OK)) < 0)
                return ret;

        return 0;
}
Example #6
0
/**
 * Select comunication interface (RS232/RS485).
 * @param sdp   Pointer to sdp_t structure, initialized by sdp_open.
 * @param ifce  One of sdp_ifce_rs232 or sdp_ifce_rs485.
 * @return      On success 0, on error negative number (error no.).
 */
int sdp_select_ifce(const sdp_t *sdp, sdp_ifce_t ifce)
{
        char buf[SDP_BUF_SIZE_MIN];
        int ret;

        if ( (ret = sdp_sselect_ifce(buf, sdp->addr, ifce)) < 0)
                return ret;

        if ( (ret = sdp_write(sdp->f_out, buf, ret)) < 0)
                return ret;

        if ( (ret = sdp_read_resp(sdp->f_in, buf, SDP_RESP_LEN_OK)) < 0)
                return ret;

        return 0;
}
Example #7
0
/**
 * Run timed program, once or repeatly.
 * @param sdp   Pointer to sdp_t structure, initialized by sdp_open.
 * @param count Count of program repeats or SDP_RUN_PROG_INF to
 *      repeat forever.
 * @return      On success 0, on error negative number (error no.).
 */
int sdp_run_program(const sdp_t *sdp, int count)
{
        int ret;
        char buf[SDP_BUF_SIZE_MIN];

        if ( (ret = sdp_srun_program(buf, sdp->addr, count)) < 0)
                return ret;

        if ( (ret = sdp_write(sdp->f_out, buf, ret)) < 0)
                return ret;

        if ( (ret = sdp_read_resp(sdp->f_in, buf, SDP_RESP_LEN_OK)) < 0)
                return ret;

        return 0;
}
Example #8
0
/**
 * Enable/disable remote operation operation mode.
 * @param sdp   Pointer to sdp_t structure, initialized by sdp_open.
 * @param enable        when 0 disable remote operation, otherwise enable.
 * @return      On success 0, on error negative number (error no.).
 */
int sdp_remote(const sdp_t *sdp, int enable)
{
        int ret;
        char buf[SDP_BUF_SIZE_MIN];

        if ( (ret = sdp_sremote(buf, sdp->addr, enable)) < 0)
                return ret;

        if ( (ret = sdp_write(sdp->f_out, buf, ret)) < 0)
                return ret;

        if ( (ret = sdp_read_resp(sdp->f_in, buf, SDP_RESP_LEN_OK)) < 0)
                return ret;

        return 0;
}
Example #9
0
/**
 * Get one or all program items from PS.
 * @param sdp   Pointer to sdp_t structure, initialized by sdp_open.
 * @param progn       program item number to get (0-19) or SDP_PROGRAM_ALL to get
 *      all program items at once.
 * @param program     pointer to sdp_program_t to store one program item or
 *      pointer to firt item of array of 20 items of type sdp_program_t to
 *      store all program items.
 * @return      On success 0, on error negative number (error no.).
 */
int sdp_get_program(const sdp_t *sdp, int progn, sdp_program_t *program)
{
        int ret;
        char buf[11*20+3+1];

        if ( (ret = sdp_sget_program(buf, sdp->addr, progn)) < 0)
                return ret;

        if ( (ret = sdp_write(sdp->f_out, buf, ret)) < 0)
                return ret;

        if ( (ret = sdp_read_resp(sdp->f_in, buf, sizeof(buf))) < 0)
                return ret;

        if ( (ret = sdp_resp_program(buf, ret, program)) < 0)
                return ret;

        return 0;
}
Example #10
0
/**
 * Get value of one or all presets stored in PS.
 * @param sdp   Pointer to sdp_t structure, initialized by sdp_open.
 * @param presn       Number of preset in range 1 - 9 to get from PS or
 *      SDP_PRESET_ALL to get all 9 preset values at once.
 * @param va_preset   Pointer to sdp_va_t, used to store retrieved velue
 *      or pointer to first item of array of 9 sdp_va_t, to store all presets.
 * @return      On success 0, on error negative number (error no.).
 */
int sdp_get_preset(const sdp_t *sdp, int presn, sdp_va_t *va_preset)
{
        int ret;
        char buf[(7*9+3+1)];

        if ( (ret = sdp_sget_preset(buf, sdp->addr, presn)) < 0)
                return ret;

        if ( (ret = sdp_write(sdp->f_out, buf, ret)) < 0)
                return ret;

        if ( (ret = sdp_read_resp(sdp->f_in, buf, sizeof(buf))) < 0)
                return ret;

        if ( (ret = sdp_resp_preset(buf, ret, va_preset)) < 0)
                return ret;

        return 0;
}
Example #11
0
/**
 * Get actual setpoint - desired current / voltage value.
 * @param sdp   Pointer to sdp_t structure, initialized by sdp_open.
 * @param       va_setpoints  pointer to sdp_va_t, used to store retrieved
 *      values.
 * @return      On success 0, on error negative number (error no.).
 */
int sdp_get_va_setpoint(const sdp_t *sdp, sdp_va_t *va_setpoints)
{
        int ret;
        char buf[SDP_BUF_SIZE_MIN];

        if ( (ret = sdp_sget_va_setpoint(buf, sdp->addr)) < 0)
                return ret;

        if ( (ret = sdp_write(sdp->f_out, buf, ret)) < 0)
                return ret;

        if ( (ret = sdp_read_resp(sdp->f_in, buf, sizeof(buf))) < 0)
                return ret;

        if ( (ret = sdp_resp_va_setpoint(buf, ret, va_setpoints)) < 0)
                return ret;

        return 0;
}
Example #12
0
/**
 * Get upper voltage limit.
 * @param sdp   Pointer to sdp_t structure, initialized by sdp_open.
 * @param volt  pointer to double, uset to store retrieved value.
 * @return      On success 0, on error negative number (error no.).
 */
int sdp_get_volt_limit(const sdp_t *sdp, double *volt)
{
        int ret;
        char buf[SDP_BUF_SIZE_MIN];

        if ( (ret = sdp_sget_volt_limit(buf, sdp->addr)) < 0)
                return ret;

        if ( (ret = sdp_write(sdp->f_out, buf, ret)) < 0)
                return ret;

        if ( (ret = sdp_read_resp(sdp->f_in, buf, sizeof(buf))) < 0)
                return ret;

        if ( (ret = sdp_resp_volt_limit(buf, ret, volt)) < 0)
                return ret;

        return 0;
}
Example #13
0
/**
 * Get SDP device address. For devices connected on RS485 this returns
 *      same value as specified on sdp_open addr field or -1 when device is
 *      not connected. For RS232 returns last set RS485 device address.
 * @param sdp   Pointer to sdp_t structure, initialized by sdp_open.
 * @return      SDP device address, or negative number (error no.) on error.
 */
int sdp_get_dev_addr(const sdp_t *sdp)
{
        int addr, ret;
        char buf[SDP_BUF_SIZE_MIN];

        if ( (ret = sdp_sget_dev_addr(buf, sdp->addr)) < 0)
                return ret;

        if ( (ret = sdp_write(sdp->f_out, buf, ret)) < 0)
                return ret;

        if ( (ret = sdp_read_resp(sdp->f_in, buf, sizeof(buf))) < 0)
                return ret;

        if ( (ret = sdp_resp_dev_addr(buf, ret, &addr)) < 0)
                return ret;

        return addr;
}
Example #14
0
/**
 * Get LCD info, return data about all informations currently shown on LCD.
 * @param sdp   Pointer to sdp_t structure, initialized by sdp_open.
 * @param lcd_info      pointer to sdp_lcd_info_raw_t where informations
 *      should be stored.
 * @return      On success 0, on error negative number (error no.).
 */
int sdp_get_lcd_info(const sdp_t *sdp, sdp_lcd_info_t *lcd_info)
{
        int ret;
        char buf[100];
        sdp_lcd_info_raw_t lcd_info_raw;

        if ( (ret = sdp_sget_lcd_info(buf, sdp->addr)) < 0)
                return ret;

        if ( (ret = sdp_write(sdp->f_out, buf, ret)) < 0)
                return ret;

        if ( (ret = sdp_read_resp(sdp->f_in, buf, sizeof(buf))) < 0)
                return ret;

        if ( (ret = sdp_resp_lcd_info(buf, ret, &lcd_info_raw)) < 0)
                return ret;

	sdp_lcd_to_data(lcd_info, &lcd_info_raw);

        return 0;
}
Example #15
0
static int adv748x_afe_s_ctrl(struct v4l2_ctrl *ctrl)
{
	struct adv748x_afe *afe = adv748x_ctrl_to_afe(ctrl);
	struct adv748x_state *state = adv748x_afe_to_state(afe);
	bool enable;
	int ret;

	ret = sdp_write(state, 0x0e, 0x00);
	if (ret < 0)
		return ret;

	switch (ctrl->id) {
	case V4L2_CID_BRIGHTNESS:
		ret = sdp_write(state, ADV748X_SDP_BRI, ctrl->val);
		break;
	case V4L2_CID_HUE:
		/* Hue is inverted according to HSL chart */
		ret = sdp_write(state, ADV748X_SDP_HUE, -ctrl->val);
		break;
	case V4L2_CID_CONTRAST:
		ret = sdp_write(state, ADV748X_SDP_CON, ctrl->val);
		break;
	case V4L2_CID_SATURATION:
		ret = sdp_write(state, ADV748X_SDP_SD_SAT_U, ctrl->val);
		if (ret)
			break;
		ret = sdp_write(state, ADV748X_SDP_SD_SAT_V, ctrl->val);
		break;
	case V4L2_CID_TEST_PATTERN:
		enable = !!ctrl->val;

		/* Enable/Disable Color bar test patterns */
		ret = sdp_clrset(state, ADV748X_SDP_DEF, ADV748X_SDP_DEF_VAL_EN,
				enable);
		if (ret)
			break;
		ret = sdp_clrset(state, ADV748X_SDP_FRP, ADV748X_SDP_FRP_MASK,
				enable ? ctrl->val - 1 : 0);
		break;
	default:
		return -EINVAL;
	}

	return ret;
}
Example #16
0
static int adv748x_afe_s_input(struct adv748x_afe *afe, unsigned int input)
{
	struct adv748x_state *state = adv748x_afe_to_state(afe);

	return sdp_write(state, ADV748X_SDP_INSEL, input);
}