Skip to content

Commit

Permalink
Allow audio channel selection (HDMI/headphones)
Browse files Browse the repository at this point in the history
Ask user for audio channel preference during initial installation.
  • Loading branch information
maxnet committed Aug 11, 2013
1 parent b8c4806 commit c6cbb01
Show file tree
Hide file tree
Showing 8 changed files with 194 additions and 29 deletions.
8 changes: 7 additions & 1 deletion BerrybootGUI2.0/bootmenudialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@ void BootMenuDialog::initialize()
ui->list->setCurrentItem(item);
}

if (_i->bootoptions().contains("sound"))
{
/* Set sound channel (HDMI/headphones) */
_i->loadSoundModule(_i->bootParam("sound"));
}

if (!_i->bootoptions().contains("nobootmenutimeout"))
{
// start timer
Expand Down Expand Up @@ -552,7 +558,7 @@ void BootMenuDialog::startNetworking()

QProcess *proc = new QProcess();
connect(proc, SIGNAL(finished(int)), proc, SLOT(deleteLater()));
proc->start("/sbin/ifup eth0");
proc->start("sh -c \"/sbin/ifup eth0 || /sbin/ifup eth0\"");
}

void BootMenuDialog::umountSystemPartition()
Expand Down
6 changes: 6 additions & 0 deletions BerrybootGUI2.0/driveformatthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@ void DriveFormatThread::run()
param += " mac_addr="+mac;
}

/* Sound channel selection (hdmi audio/headphones) */
if (!_i->sound().isEmpty())
{
param += " sound="+_i->sound();
}

QByteArray qmap = _i->keyboardlayout().toAscii();
if (!qmap.isEmpty() && qmap != "us")
param += " qmap="+qmap;
Expand Down
1 change: 1 addition & 0 deletions BerrybootGUI2.0/icons.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,6 @@
<file alias="wallpaper.jpg">icons/luminous_lines.jpg</file>
<file>icons/help.png</file>
<file>icons/document_revert.png</file>
<file>icons/audio_headset.png</file>
</qresource>
</RCC>
29 changes: 29 additions & 0 deletions BerrybootGUI2.0/installer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,16 @@ bool Installer::fixateMAC() const
return _fixMAC;
}

void Installer::setSound(const QByteArray &sound)
{
_sound = sound;
}

QByteArray Installer::sound() const
{
return _sound;
}

bool Installer::isSquashFSimage(QFile &f)
{
quint32 magic = 0;
Expand Down Expand Up @@ -551,6 +561,25 @@ void Installer::loadCryptoModules()
QProcess::execute("/sbin/modprobe algif_hash");
}

void Installer::loadSoundModule(const QByteArray &channel)
{
if (cpuinfo().contains("BCM2708"))
{
/* Raspberry Pi */
prepareDrivers();
QProcess::execute("/sbin/modprobe snd-bcm2835");

if (channel == "headphones")
{
QProcess::execute("amixer cset numid=3 1");
}
else if (channel == "hdmi")
{
QProcess::execute("amixer cset numid=3 2");
}
}
}

void Installer::startWifi()
{
loadDrivers();
Expand Down
5 changes: 4 additions & 1 deletion BerrybootGUI2.0/installer.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class Installer : public QObject
void prepareDrivers();
void loadDrivers();
void loadCryptoModules();
void loadSoundModule(const QByteArray &channel);
void startWifi();

void setKeyboardLayout(const QString &layout);
Expand All @@ -67,6 +68,8 @@ class Installer : public QObject
bool disableOverscan() const;
void setFixateMAC(bool fix);
bool fixateMAC() const;
void setSound(const QByteArray &sound);
QByteArray sound() const;

QMap<QString,QString> listInstalledImages();
QString imageFilenameToFriendlyName(const QString &name);
Expand Down Expand Up @@ -99,7 +102,7 @@ public slots:
QString _keyboardlayout, _timezone;
bool _disableOverscan, _fixMAC;
QSettings *_settings;
QByteArray _bootoptions;
QByteArray _bootoptions, _sound;

void log_error(const QString &msg);

Expand Down
4 changes: 4 additions & 0 deletions BerrybootGUI2.0/localedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ void LocaleDialog::done(int r)
_i->setTimezone(ui->timezoneCombo->currentText());
_i->setDisableOverscan(ui->disableOverscanRadio->isChecked());
_i->setFixateMAC(_i->hasDynamicMAC() && ui->fixMACbox->isChecked());
if (ui->audioHDMIradio->isChecked())
_i->setSound("hdmi");
else if (ui->audioHeadphonesRadio->isChecked())
_i->setSound("headphones");
bool wifi = ui->wifiRadio->isChecked();

if (_gbd)
Expand Down
132 changes: 108 additions & 24 deletions BerrybootGUI2.0/localedialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<property name="windowTitle">
<string>Welcome</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="font">
<font>
Expand All @@ -26,27 +26,12 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Welcome to BerryBoot installation. Please double check the following settings, and press &quot;ok&quot;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<item row="2" column="0" rowspan="2" colspan="3">
<widget class="QGroupBox" name="overscanGroupBox">
<property name="minimumSize">
<size>
<width>0</width>
<height>110</height>
<height>100</height>
</size>
</property>
<property name="font">
Expand Down Expand Up @@ -85,12 +70,18 @@
</layout>
</widget>
</item>
<item>
<item row="4" column="0">
<widget class="QGroupBox" name="groupBox_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>75</height>
<width>240</width>
<height>95</height>
</size>
</property>
<property name="font">
Expand Down Expand Up @@ -157,7 +148,7 @@
</layout>
</widget>
</item>
<item>
<item row="5" column="0" colspan="3">
<widget class="QGroupBox" name="groupBox_2">
<property name="minimumSize">
<size>
Expand Down Expand Up @@ -249,7 +240,100 @@
</layout>
</widget>
</item>
<item>
<item row="4" column="1" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>95</height>
</size>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="title">
<string>Audio</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="audioAutoRadio">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Auto</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="audioHDMIradio">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>HDMI</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="audioHeadphonesRadio">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Headphones</string>
</property>
<property name="icon">
<iconset resource="icons.qrc">
<normaloff>:/icons/audio_headset.png</normaloff>:/icons/audio_headset.png</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Welcome to BerryBoot installation. Please double check the following settings, and press &quot;ok&quot;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="0" colspan="3">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
Expand Down
38 changes: 35 additions & 3 deletions buildroot-2012.05/.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# Automatically generated make config: don't edit
# Buildroot 2012.05-gb49fa59-dirty Configuration
# Buildroot 2012.05-gb8c4806-dirty Configuration
#
BR2_HAVE_DOT_CONFIG=y
BR2_arm=y
Expand Down Expand Up @@ -239,7 +239,24 @@ BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y
#
# Audio and video applications
#
# BR2_PACKAGE_ALSA_UTILS is not set
BR2_PACKAGE_ALSA_UTILS=y

#
# ALSA utils selection
#
# BR2_PACKAGE_ALSA_UTILS_ALSACONF is not set
# BR2_PACKAGE_ALSA_UTILS_ALSACTL is not set
# BR2_PACKAGE_ALSA_UTILS_ALSAMIXER is not set
# BR2_PACKAGE_ALSA_UTILS_AMIDI is not set
BR2_PACKAGE_ALSA_UTILS_AMIXER=y
# BR2_PACKAGE_ALSA_UTILS_APLAY is not set
# BR2_PACKAGE_ALSA_UTILS_IECSET is not set
# BR2_PACKAGE_ALSA_UTILS_ACONNECT is not set
# BR2_PACKAGE_ALSA_UTILS_APLAYMIDI is not set
# BR2_PACKAGE_ALSA_UTILS_ARECORDMIDI is not set
# BR2_PACKAGE_ALSA_UTILS_ASEQDUMP is not set
# BR2_PACKAGE_ALSA_UTILS_ASEQNET is not set
# BR2_PACKAGE_ALSA_UTILS_SPEAKER_TEST is not set
# BR2_PACKAGE_AUMIX is not set
# BR2_PACKAGE_BELLAGIO is not set
# BR2_PACKAGE_FAAD2 is not set
Expand Down Expand Up @@ -617,7 +634,22 @@ BR2_PACKAGE_SQUASHFS_LZO=y
#
# Audio/Sound
#
# BR2_PACKAGE_ALSA_LIB is not set
BR2_PACKAGE_ALSA_LIB=y

#
# ALSA lib selection
#
BR2_PACKAGE_ALSA_LIB_DEVDIR="/dev/snd"
BR2_PACKAGE_ALSA_LIB_PCM_PLUGINS=""
BR2_PACKAGE_ALSA_LIB_CTL_PLUGINS="all"
# BR2_PACKAGE_ALSA_LIB_ALOAD is not set
BR2_PACKAGE_ALSA_LIB_MIXER=y
BR2_PACKAGE_ALSA_LIB_PCM=y
# BR2_PACKAGE_ALSA_LIB_RAWMIDI is not set
# BR2_PACKAGE_ALSA_LIB_HWDEP is not set
BR2_PACKAGE_ALSA_LIB_SEQ=y
# BR2_PACKAGE_ALSA_LIB_ALISP is not set
# BR2_PACKAGE_ALSA_LIB_OLD_SYMBOLS is not set
# BR2_PACKAGE_AUDIOFILE is not set
# BR2_PACKAGE_LIBAO is not set
# BR2_PACKAGE_LIBCDAUDIO is not set
Expand Down

0 comments on commit c6cbb01

Please sign in to comment.