Formatting in snd_audiopci.c

This commit is contained in:
Jasmine Iwanek 2025-01-02 20:29:40 -05:00
parent e9ea707f70
commit 04520db27f

View file

@ -145,10 +145,10 @@ typedef struct es137x_t {
uint32_t calc_sample_rate;
uint32_t calc_sample_rate_synth;
double interp_factor;
double interp_factor;
uint32_t interp_step;
double interp_factor_synth;
double interp_factor_synth;
uint32_t interp_step_synth;
uint32_t step_pcm;
@ -156,18 +156,20 @@ typedef struct es137x_t {
} es137x_t;
static const double akm4531_att_2dbstep_5bits[] = {
// clang-format off
25.0, 32.0, 41.0, 51.0, 65.0, 82.0, 103.0, 130.0,
164.0, 206.0, 260.0, 327.0, 412.0, 519.0, 653.0, 822.0,
1036.0, 1304.0, 1641.0, 2067.0, 2602.0, 3276.0, 4125.0, 5192.0,
6537.0, 8230.0, 10362.0, 13044.0, 16422.0, 20674.0, 26027.0, 32767.0
// clang-format on
};
static double akm4531_gain_2dbstep_5bits[0x20];
#define AUDIOPCI_ES1370 0x50001274
#define AUDIOPCI_ES1371 0x13710200
#define AUDIOPCI_ES1373 0x13710400
#define AUDIOPCI_CT5880 0x58800400
#define AUDIOPCI_ES1370 0x50001274
#define AUDIOPCI_ES1371 0x13710200
#define AUDIOPCI_ES1373 0x13710400
#define AUDIOPCI_CT5880 0x58800400
#define LEGACY_SB_ADDR (1 << 29)
#define LEGACY_SSCAPE_ADDR_SHIFT 27
@ -365,7 +367,7 @@ es137x_reset_fifo(es137x_t *dev)
static void
akm4531_reset(es137x_t *dev)
{
akm4531_t* codec = &dev->akm_codec;
akm4531_t *codec = &dev->akm_codec;
memset(codec->registers, 0, sizeof(codec->registers));
@ -382,8 +384,10 @@ akm4531_reset(es137x_t *dev)
codec->registers[0x16] = 0x3;
}
static double lerp(double v0, double v1, double t) {
return (1. - t) * v0 + t * v1;
static double
lerp(double v0, double v1, double t)
{
return (1. - t) * v0 + t * v1;
}
static void
@ -394,34 +398,34 @@ es1370_calc_sample_rate(es137x_t *dev)
dev->calc_sample_rate = 1411200 / (((dev->int_ctrl >> 16) & 0x1fff) + 2);
//pclog("ES1370 calc sample rate %u\n", dev->calc_sample_rate);
// pclog("ES1370 calc sample rate %u\n", dev->calc_sample_rate);
dev->interp_factor = 1.0;
dev->interp_step = 1;
dev->interp_step = 1;
if (dev->calc_sample_rate >= 44100 || dev->calc_sample_rate < 11025) {
dev->interp_factor = 1.0;
dev->interp_step = 1;
dev->interp_factor = 1.0;
dev->interp_step = 1;
dev->calc_sample_rate = 44100;
}
if (dev->calc_sample_rate == 22050) {
dev->interp_factor = 0.5;
dev->interp_step = 2;
dev->interp_step = 2;
}
if (dev->calc_sample_rate == 11025) {
dev->interp_factor = 0.25;
dev->interp_step = 4;
dev->interp_step = 4;
}
if ((((dev->int_ctrl >> 16) & 0x1fff) + 2) == 256) {
/* 5512.5 Hz */
dev->interp_factor = 0.125;
dev->interp_step = 8;
dev->interp_factor = 0.125;
dev->interp_step = 8;
dev->calc_sample_rate = 5512;
}
dev->calc_sample_rate_synth = 44100 / (1 << ((dev->int_ctrl >> 12) & 3));
dev->interp_factor_synth = 1. / (double)(1 << ((dev->int_ctrl >> 12) & 3));
dev->interp_step_synth = (1 << ((dev->int_ctrl >> 12) & 3));
dev->interp_factor_synth = 1. / (double) (1 << ((dev->int_ctrl >> 12) & 3));
dev->interp_step_synth = (1 << ((dev->int_ctrl >> 12) & 3));
}
static void
@ -432,7 +436,7 @@ es137x_reset(void *priv)
nmi = 0;
/* Default subsystem ID. */
dev->subsys_lock = 0x00;
dev->subsys_lock = 0x00;
*((uint16_t *) &dev->subsys_id[0]) = (dev->type == AUDIOPCI_ES1370) ? 0x4942 : 0x1274;
*((uint16_t *) &dev->subsys_id[2]) = (dev->type == AUDIOPCI_ES1370) ? 0x4c4c : 0x1371;
@ -1123,7 +1127,7 @@ es137x_outb(uint16_t port, uint8_t val, void *priv)
dev->dac[1].prev_out_r = 0;
es137x_fetch(dev, 1);
}
//pclog("INTCTRL 0x%02X\n", val & 0xff);
// pclog("INTCTRL 0x%02X\n", val & 0xff);
dev->int_ctrl = (dev->int_ctrl & 0xffffff00) | val;
break;
case 0x01:
@ -1278,7 +1282,7 @@ es137x_outw(uint16_t port, uint16_t val, void *priv)
dev->step_pcm = dev->interp_step;
es137x_fetch(dev, 1);
}
//pclog("INTCTRL 0x%02X\n", val & 0xff);
// pclog("INTCTRL 0x%02X\n", val & 0xff);
dev->int_ctrl = (dev->int_ctrl & 0xffff0000) | val;
break;
case 0x02:
@ -1300,7 +1304,7 @@ es137x_outw(uint16_t port, uint16_t val, void *priv)
case 0x10:
if (dev->type != AUDIOPCI_ES1370)
break;
dev->akm_codec.registers[(val >> 8) & 0xFF] = val & 0xFF;
if ((val >> 8) == 0x16 && !(val & 1))
akm4531_reset(dev);
@ -1376,36 +1380,36 @@ es137x_outl(uint16_t port, uint32_t val, void *priv)
/* Interrupt/Chip Select Control Register, Address 00H
Addressable as byte, word, longword */
case 0x00:
{
uint8_t dac1start = 0, dac2start = 0;
if (!(dev->int_ctrl & INT_DAC1_EN) && (val & INT_DAC1_EN)) {
dev->dac[0].addr = dev->dac[0].addr_latch;
dev->dac[0].buffer_pos = 0;
dev->dac[0].buffer_pos_end = 0;
dev->dac[0].prev_out_l = 0;
dev->dac[0].prev_out_r = 0;
dac1start = 1;
es137x_fetch(dev, 0);
{
uint8_t dac1start = 0, dac2start = 0;
if (!(dev->int_ctrl & INT_DAC1_EN) && (val & INT_DAC1_EN)) {
dev->dac[0].addr = dev->dac[0].addr_latch;
dev->dac[0].buffer_pos = 0;
dev->dac[0].buffer_pos_end = 0;
dev->dac[0].prev_out_l = 0;
dev->dac[0].prev_out_r = 0;
dac1start = 1;
es137x_fetch(dev, 0);
}
if (!(dev->int_ctrl & INT_DAC2_EN) && (val & INT_DAC2_EN)) {
dev->dac[1].addr = dev->dac[1].addr_latch;
dev->dac[1].buffer_pos = 0;
dev->dac[1].buffer_pos_end = 0;
dev->dac[1].prev_out_l = 0;
dev->dac[1].prev_out_r = 0;
dac2start = 1;
es137x_fetch(dev, 1);
}
// pclog("INTCTRL 0x%02X\n", val & 0xff);
dev->int_ctrl = val;
gameport_remap(dev->gameport, 0x200 | ((val & 0x03000000) >> 21));
es1370_calc_sample_rate(dev);
if (dac1start)
dev->step_synth = dev->interp_step_synth;
if (dac2start)
dev->step_pcm = dev->interp_step;
break;
}
if (!(dev->int_ctrl & INT_DAC2_EN) && (val & INT_DAC2_EN)) {
dev->dac[1].addr = dev->dac[1].addr_latch;
dev->dac[1].buffer_pos = 0;
dev->dac[1].buffer_pos_end = 0;
dev->dac[1].prev_out_l = 0;
dev->dac[1].prev_out_r = 0;
dac2start = 1;
es137x_fetch(dev, 1);
}
//pclog("INTCTRL 0x%02X\n", val & 0xff);
dev->int_ctrl = val;
gameport_remap(dev->gameport, 0x200 | ((val & 0x03000000) >> 21));
es1370_calc_sample_rate(dev);
if (dac1start)
dev->step_synth = dev->interp_step_synth;
if (dac2start)
dev->step_pcm = dev->interp_step;
break;
}
/* Interrupt/Chip Select Status Register, Address 04H
Addressable as longword only */
@ -1875,12 +1879,12 @@ es1370_pci_read(int func, int addr, void *priv)
return 0x00;
switch (addr) {
case 0x00: /* Vendor ID */
case 0x00: /* Vendor ID */
return 0x74; /* Ensoniq */
case 0x01:
return 0x12;
case 0x02: /* Device ID */
case 0x02: /* Device ID */
return 0x00; /* ES1370 */
case 0x03:
return 0x50;
@ -1890,12 +1894,12 @@ es1370_pci_read(int func, int addr, void *priv)
case 0x05:
return dev->pci_serr;
case 0x06: /* Status TODO */
case 0x06: /* Status TODO */
return 0x10; /* Supports ACPI */
case 0x07:
return 0x00;
case 0x08: /* Class Code & Revision ID */
case 0x08: /* Class Code & Revision ID */
return 0x00; /* Revision ID - 0x00 is actual Ensoniq-branded ES1370 */
case 0x09:
return 0x00; /* Multimedia audio device */
@ -1909,7 +1913,7 @@ es1370_pci_read(int func, int addr, void *priv)
// case 0x0e: /* Header Type TODO */
// case 0x0f: /* BIST TODO */
case 0x10: /* Base Address TODO */
case 0x10: /* Base Address TODO */
return 0x01 | (dev->base_addr & 0xc0); /* memBaseAddr */
case 0x11:
return dev->base_addr >> 8;
@ -2637,8 +2641,8 @@ es1370_init(const device_t *info)
dev->dac[1].vol_l = 1 << 12;
dev->dac[1].vol_r = 1 << 12;
dev->pcm_vol_l = 1 << 15;
dev->pcm_vol_r = 1 << 15;
dev->pcm_vol_l = 1 << 15;
dev->pcm_vol_r = 1 << 15;
dev->master_vol_l = 1 << 15;
dev->master_vol_r = 1 << 15;
@ -2649,7 +2653,7 @@ es1370_init(const device_t *info)
es137x_speed_changed(dev);
for (int i = 0; i < 0x20; i++) {
double attn = (12.0 - (i * 2.0));
double attn = (12.0 - (i * 2.0));
akm4531_gain_2dbstep_5bits[i] = pow(10, attn / 10.) * 32767.0;
}
@ -2707,7 +2711,7 @@ es137x_speed_changed(void *priv)
}
static const device_config_t es1370_config[] = {
// clang-format off
// clang-format off
{
.name = "receive_input",
.description = "Receive input (MIDI)",
@ -2716,11 +2720,11 @@ static const device_config_t es1370_config[] = {
.default_int = 1
},
{ .name = "", .description = "", .type = CONFIG_END }
// clang-format on
// clang-format on
};
static const device_config_t es1371_config[] = {
// clang-format off
// clang-format off
{
.name = "codec",
.description = "Codec",
@ -2746,11 +2750,11 @@ static const device_config_t es1371_config[] = {
.default_int = 1
},
{ .name = "", .description = "", .type = CONFIG_END }
// clang-format on
// clang-format on
};
static const device_config_t es1373_config[] = {
// clang-format off
// clang-format off
{
.name = "codec",
.description = "Codec",
@ -2780,11 +2784,11 @@ static const device_config_t es1373_config[] = {
.default_int = 1
},
{ .name = "", .description = "", .type = CONFIG_END }
// clang-format on
// clang-format on
};
static const device_config_t ct5880_config[] = {
// clang-format off
// clang-format off
{
.name = "codec",
.description = "Codec",
@ -2810,11 +2814,11 @@ static const device_config_t ct5880_config[] = {
.default_int = 1
},
{ .name = "", .description = "", .type = CONFIG_END }
// clang-format on
// clang-format on
};
static const device_config_t es1371_onboard_config[] = {
// clang-format off
// clang-format off
{
.name = "receive_input",
.description = "Receive MIDI input",
@ -2823,7 +2827,7 @@ static const device_config_t es1371_onboard_config[] = {
.default_int = 1
},
{ .name = "", .description = "", .type = CONFIG_END }
// clang-format on
// clang-format on
};
const device_t es1370_device = {