/* Sets the DAC output in one of the three states.  */
int32_t ad5791_dac_ouput_state(struct ad5791_dev *dev, uint8_t state)
/* Sets the DAC output in one of the three states.  */
int32_t ad5791_dac_ouput_state(struct ad5791_dev *dev, uint8_t state)
{
	uint32_t old_ctrl = 0;
	uint32_t new_ctrl = 0;
	int32_t status = 0;
	status = ad5791_get_register_value(dev,
					   AD5791_REG_CTRL);
	if(status < 0) {
		return status;
	}
	old_ctrl = status;
	old_ctrl = old_ctrl & ~(AD5791_CTRL_DACTRI | AD5791_CTRL_OPGND);
	new_ctrl = old_ctrl |
		   ((state << 2) & (AD5791_CTRL_DACTRI | AD5791_CTRL_OPGND));
	status = ad5791_set_register_value(dev,
					   AD5791_REG_CTRL,
					   new_ctrl);
	return status;
}