linux/drivers/media/usb/stk1160/stk1160-ac97.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * STK1160 driver
 *
 * Copyright (C) 2012 Ezequiel Garcia
 * <elezegarcia--a.t--gmail.com>
 *
 * Copyright (C) 2016 Marcel Hasler
 * <mahasler--a.t--gmail.com>
 *
 * Based on Easycap driver by R.M. Thomas
 *	Copyright (C) 2010 R.M. Thomas
 *	<rmthomas--a.t--sciolus.org>
 */

#include <linux/delay.h>

#include "stk1160.h"
#include "stk1160-reg.h"

static int stk1160_ac97_wait_transfer_complete(struct stk1160 *dev)
{}

static void stk1160_write_ac97(struct stk1160 *dev, u16 reg, u16 value)
{}

#ifdef DEBUG
static u16 stk1160_read_ac97(struct stk1160 *dev, u16 reg)
{
	u8 vall = 0;
	u8 valh = 0;

	/* Set codec register address */
	stk1160_write_reg(dev, STK1160_AC97_ADDR, reg);

	/* Set command read bit to initiate read operation */
	stk1160_write_reg(dev, STK1160_AC97CTL_0, 0x8b);

	/* Wait for command read bit to be cleared */
	if (stk1160_ac97_wait_transfer_complete(dev) < 0)
		return 0;


	/* Retrieve register value */
	stk1160_read_reg(dev, STK1160_AC97_CMD, &vall);
	stk1160_read_reg(dev, STK1160_AC97_CMD + 1, &valh);

	return (valh << 8) | vall;
}

void stk1160_ac97_dump_regs(struct stk1160 *dev)
{
	u16 value;

	value = stk1160_read_ac97(dev, 0x12); /* CD volume */
	stk1160_dbg("0x12 == 0x%04x", value);

	value = stk1160_read_ac97(dev, 0x10); /* Line-in volume */
	stk1160_dbg("0x10 == 0x%04x", value);

	value = stk1160_read_ac97(dev, 0x0e); /* MIC volume (mono) */
	stk1160_dbg("0x0e == 0x%04x", value);

	value = stk1160_read_ac97(dev, 0x16); /* Aux volume */
	stk1160_dbg("0x16 == 0x%04x", value);

	value = stk1160_read_ac97(dev, 0x1a); /* Record select */
	stk1160_dbg("0x1a == 0x%04x", value);

	value = stk1160_read_ac97(dev, 0x02); /* Master volume */
	stk1160_dbg("0x02 == 0x%04x", value);

	value = stk1160_read_ac97(dev, 0x1c); /* Record gain */
	stk1160_dbg("0x1c == 0x%04x", value);
}
#endif

static int stk1160_has_audio(struct stk1160 *dev)
{}

static int stk1160_has_ac97(struct stk1160 *dev)
{}

void stk1160_ac97_setup(struct stk1160 *dev)
{}