Skip to content

Commit

Permalink
Volume COntrol for Internal Speaker
Browse files Browse the repository at this point in the history
  • Loading branch information
markusC64 authored and markusC64 committed Mar 18, 2017
1 parent 08604b2 commit 274441c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
11 changes: 7 additions & 4 deletions fpga/altera/u2p_io.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use IEEE.numeric_std.all;
use work.io_bus_pkg.all;

entity u2p_io is
port (
clock : in std_logic;
reset : in std_logic;
port (
clock : in std_logic;
reset : in std_logic;

io_req : in t_io_req;
io_resp : out t_io_resp;
Expand All @@ -29,8 +29,8 @@ port (
hub_reset_n : out std_logic;
speaker_en : out std_logic;
ulpi_reset : out std_logic;
speaker_vol : out std_logic_vector(3 downto 0);
buffer_en : out std_logic );

end entity;

architecture rtl of u2p_io is
Expand All @@ -39,6 +39,7 @@ architecture rtl of u2p_io is
signal i2c_scl_out : std_logic;
signal i2c_sda_out : std_logic;
signal speaker_en_i : std_logic;
signal speaker_vol_i : std_logic_vector(3 downto 0);
signal hub_reset_i : std_logic;
signal ulpi_reset_i : std_logic;
begin
Expand Down Expand Up @@ -113,6 +114,7 @@ begin
mdio_o <= io_req.data(0);
when X"C" =>
speaker_en_i <= io_req.data(0);
speaker_vol_i <= io_req.data(4 downto 1);
when X"D" =>
hub_reset_i <= io_req.data(0);
when X"E" =>
Expand All @@ -133,6 +135,7 @@ begin

mdc <= mdc_out;
speaker_en <= speaker_en_i;
speaker_vol <= speaker_vol_i;
hub_reset_n <= not (hub_reset_i or reset);
ulpi_reset <= ulpi_reset_i or reset;

Expand Down
3 changes: 3 additions & 0 deletions fpga/fpga_top/ultimate_fpga/vhdl_source/u2p_nios2_solo.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ architecture rtl of u2p_nios_solo is
signal audio_speaker : signed(12 downto 0);
signal audio_left : signed(18 downto 0);
signal audio_right : signed(18 downto 0);
signal SPEAKER_VOL : std_logic_vector(3 downto 0);
begin
process(RMII_REFCLK)
begin
Expand Down Expand Up @@ -379,6 +380,7 @@ begin
board_rev => not BOARD_REVn,
eth_irq_i => ETH_IRQn,
speaker_en => SPEAKER_ENABLE,
speaker_vol => SPEAKER_VOL,
hub_reset_n=> HUB_RESETn,
ulpi_reset => ulpi_reset_req,
buffer_en => buffer_en
Expand Down Expand Up @@ -475,6 +477,7 @@ begin
audio_speaker => audio_speaker,
audio_left => audio_left,
audio_right => audio_right,
speaker_vol => SPEAKER_VOL,

-- IEC bus
iec_reset_i => IEC_RESET,
Expand Down
8 changes: 6 additions & 2 deletions fpga/fpga_top/ultimate_fpga/vhdl_source/ultimate_logic_32.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ port (
audio_speaker : out signed(12 downto 0);
audio_left : out signed(18 downto 0);
audio_right : out signed(18 downto 0);
speaker_vol : in std_logic_vector(3 downto 0);

-- IEC bus
-- actual levels of the pins --
Expand Down Expand Up @@ -378,6 +379,9 @@ architecture logic of ultimate_logic_32 is
signal sys_irq_eth_rx : std_logic := '0';
signal misc_io : std_logic_vector(7 downto 0);
signal profiler_irq_flags : std_logic_vector(7 downto 0);


signal audio_speaker_tmp : signed(17 downto 0);
begin
r_mb: if g_microblaze generate
signal invalidate : std_logic;
Expand Down Expand Up @@ -517,8 +521,8 @@ begin
-- audio out
audio_sample => drive_sample_1 );
end generate;
audio_speaker <= drive_sample_1;

audio_speaker_tmp <= drive_sample_1 * signed(resize(unsigned(speaker_vol),5));
audio_speaker <= audio_speaker_tmp(16 downto 4);

r_drive_2: if g_drive_1541_2 generate
begin
Expand Down
6 changes: 4 additions & 2 deletions software/io/audio/audio_select.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ uint8_t sid_offsets[] = { 0x40, 0x42, 0x48, 0x50, 0x58, 0x60, 0x68, 0x70, 0x78,
const char *sid_voices[] = { "Standard", "8 Voices" };
const char *en_dis3[] = { "Disabled", "Enabled" };
const char *sidchip_sel[] = { "6581", "8580" };
const char *speaker_vol[] = { "Disabled", "Vol 1", "Vol 2", "Vol 3", "Vol 4", "Vol 5", "Vol 6", "Vol 7", "Vol 8", "Vol 9", "Vol 10", "Vol 11", "Vol 12", "Vol 13", "Vol 14", "Vol 15" };

struct t_cfg_definition audio_cfg[] = {
{ CFG_AUDIO_SELECT_LEFT, CFG_TYPE_ENUM, "Left Channel Output", "%s", aud_choices, 0, 7, 0 },
Expand All @@ -69,7 +70,7 @@ struct t_cfg_definition audio_cfg_no_sid[] = {
{ CFG_TYPE_END, CFG_TYPE_END, "", "", NULL, 0, 0, 0 } };

struct t_cfg_definition audio_cfg_plus[] = {
{ CFG_AUDIO_SPEAKER_EN, CFG_TYPE_ENUM, "Built-in Speaker (Drive-A)", "%s", en_dis3, 0, 1, 1 },
{ CFG_AUDIO_SPEAKER_EN, CFG_TYPE_ENUM, "Built-in Speaker (Drive-A)", "%s", speaker_vol, 0, 15, 1 },
{ CFG_AUDIO_SELECT_LEFT, CFG_TYPE_ENUM, "Left Channel Output", "%s", aud_choices3,0, 7, 4 },
{ CFG_AUDIO_SELECT_RIGHT, CFG_TYPE_ENUM, "Right Channel Output", "%s", aud_choices3,0, 7, 5 },
{ CFG_AUDIO_SID_ENABLE_L, CFG_TYPE_ENUM, "SID Left", "%s", en_dis3, 0, 1, 1 },
Expand Down Expand Up @@ -152,7 +153,8 @@ void AudioConfig :: effectuate_settings()
set_sid_coefficients();
}
if(getFpgaCapabilities() & CAPAB_ULTIMATE2PLUS) {
U2PIO_SPEAKER_EN = cfg->get_value(CFG_AUDIO_SPEAKER_EN);
unsigned char tmp = cfg->get_value(CFG_AUDIO_SPEAKER_EN);
U2PIO_SPEAKER_EN = (tmp << 1) | (tmp != 0);
}
}

Expand Down

0 comments on commit 274441c

Please sign in to comment.