The first thing to do is to download the replicant sources:
[wiki:BuildDream] can be used as a reference: download and build the sources for your device.
Let's say the user has a HTC Wildfire. It is useful to know the codename of the device in question, which is "Buzz" in case
of the Wildfire.
add_lunch_combo generic_buzz-eng
}}}
Note that the developper is supposed to know the code of his device, that is to say that the htc wildfire correspond to the "buzz" codename.
then instead of typing that:
{{{
lunch cyanogen_dream_sapphire-eng
}}}
type what corresponds to your device:
{{{
lunch cyanogen_buzz-eng
}}}
Note that "cyanogen" was substituted for "generic" in the string. The build must use the Cyanogen vendor instead of the "generic" vendor
to avoid build failure due to missing code overlays. If you're really curious about the correct string, see vendor/cyanogen/vendorsetup.sh.
Then build the source, backup what's on your device, including the operating system, and flash the new replicant image.
Then test what works and what doesn't.
The images are located in
{{{
out/target/product/dream_sapphire
}}}
in the case of the HTC Dream. You need to look in the path that corresponds to your device.
The source code you just built contains some free replacements for the proprietary
libraries shipped by your phone vendor with the default firmware.
A list of proprietary libraries is available in
{{{
device/htc/dream_sapphire/extract-files.sh
}}}
Note: don't run this file, just look at it. If you run it, the proprietary files will be copied from your phone into the build tree. A build containing proprietary files would put you and
your users at risk. Additionally, it is illegal to redistribute such build, because the libraries are not redistributable(the copyright owner didn't allow you to redistribute them).
=== RIL test ===
I will take the example of how to use the free RIL (Radio Interface Library) to see if it works fine without modifications:
The proprietary RIL library (which you don't have in the phone) location is found looking at the extract-files.sh
here's a part of extract-files.sh:
{{{
adb pull /system/lib/libhtc_ril.so ../../../vendor/htc/$DEVICE/proprietary/libhtc_ril.so
}}}
Note: don't run this command, just look at it. If you run it, the proprietary files will be copied from your phone into the build tree. A build containing proprietary files would put you and
your users at risk. Additionally, it is illegal to redistribute such build, because the libraries are not redistributable(the copyright owner didn't allow you to redistribute them).
Then change the following properties and reboot:
{{{
./adb shell reboot
}}}
Then try the reference RIL.
On the HTC Dream the following proprietary libraries were replaced:
(Refer to [wiki:ProprietaryHtcDreamLibsReplacement] for more up to date details(or fix it if it's less recent))
The first thing you will have to do is to modify the build system.
The key thing to do is to change
=== RIL ===
If the RIL you previously tried works fine, why not switching to it...directly in the build system.
Here's the diff between A working RIL and a non-working RIL for the htcdream:
{{{
android_device_htc_dream_sapphire$ git diff 5593d2899203ec378c306701788f1c43af9a6935 -- full_dream_sapphire.mk
diff --git a/full_dream_sapphire.mk b/full_dream_sapphire.mk
index 9ec7feb..eb1b956 100644
--- a/full_dream_sapphire.mk
+++ b/full_dream_sapphire.mk@ -40,7 +40,8
@ PRODUCT_PROPERTY_OVERRIDES := \
ro.media.dec.jpeg.memcap=10000000
PRODUCT_PROPERTY_OVERRIDES = \
- rild.libpath=/system/lib/libhtc_ril.so \
rild.libpath=/system/lib/libreference-ril.so \
+ rild.libargs=-d/dev/smd0 \
wifi.interface=tiwlan0
}}}
Note that full_dream_sapphire.mk is located here:
{{{
device/htc/dream_sapphire/full_dream_sapphire.mk
}}}
The diff is self-explanatory and how to do the change is left as an exercise to the reader.
In case the RIL need to be modified the sources are in :
{{{
hardware/ril/reference-ril
}}}
They are written in C.
=== Audio libraries ===
On the HTC dream the audio libraries were modified.
If your device is an msm7k "CPU" (in reality it's called a SOC, or system on a chip), it already contain the routing fix. Else I will analyse the following commit to give hints on how to modify an audio library:
{{{
commit e0b55a19b2fc004915503ebdfd7c4c02c4264611
Author: Denis 'GNUtoo' Carikli <GNUtoo@no-log.org>
Date: Thu Dec 23 16:49:35 2010 +0100
libaudio: AudioHardware: don't depend on the proprietary libhtc_acoustic.so for routing
/system/lib/libhtc_acoustic.so is proprietary(and not redistributable),
so we don't depend on it, but still we want audio routing
This commit was inspired from a previous commit I made(for replicant 1.5):
http://gitorious.org/replicant/msm7k/commit/6d13023d634e54814ecc74b22f77de27f1b8ac2c
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@no-log.org>
diff --git a/libaudio/AudioHardware.cpp b/libaudio/AudioHardware.cpp
index 78b6a3e..af63e5a 100644
--- a/libaudio/AudioHardware.cpp
++ b/libaudio/AudioHardware.cpp@ -43,6 +43,74
@ const uint32_t AudioHardware::inputSamplingRates[] = {
8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000
};
// ----------------------------------------------------------------------------
+static int snd_get_endpoint(int cnt,msm_snd_endpoint * ept){
int fd;
+ int status;
+ fd = open("/dev/msm_snd",O_RDWR);
+ if (fd < 0) {
+ LOGE;
+ close(fd);
+ return -1;
+ }
+ status = ioctl(fd,SND_GET_ENDPOINT, ept);
+ close(fd);
+ return status;
}
static int snd_get_num(){
int fd;
+ int status;
+ int mNumSndEndpoints;
+ fd = open("/dev/msm_snd",O_RDWR);
+ if (fd < 0) {
+ LOGE;
+ return -1;
+ }
if(ioctl(fd,SND_GET_NUM_ENDPOINTS,&mNumSndEndpoints)<0 ) {
+ LOGE;
+ close(fd);
+ return -1;
+ }
+ close(fd);
+ return mNumSndEndpoints;
}
static int msm72xx_enable_audpp (uint16_t enable_mask)
{
+ int fd;
+ fd = open ("/dev/msm_pcm_ctl", O_RDWR);
+ if (fd < 0) {
+ LOGE ("Cannot open audio device");
+ return -1;
+ }
if (enable_mask & ADRC_ENABLE) {
+ enable_mask &= ~ADRC_ENABLE;
+ }
+ if (enable_mask & EQ_ENABLE) {
+ enable_mask &= ~EQ_ENABLE;
+ }
+ if (enable_mask & RX_IIR_ENABLE) {
+ enable_mask &= ~RX_IIR_ENABLE;
+ }
printf ("msm72xx_enable_audpp: 0x%04x", enable_mask);
+ if (ioctl (fd, AUDIO_ENABLE_AUDPP, &enable_mask) < 0) {
+ LOGE ("enable audpp error");
+ close (fd);
+ return -1;
+ }
close (fd);
+ return 0;
}
static int set_acoustic_parameters(){
return 0;
+}
AudioHardware::AudioHardware() :
mInit(false), mMicMute(true), mBluetoothNrec(true), mBluetoothId(0),
@ -63,38 +131,10
@ AudioHardware::AudioHardware() :
SND_DEVICE_BT_EC_OFF(-1)
{
- int (*snd_get_num)();
- int (*snd_get_endpoint)(int, msm_snd_endpoint *);
- int (*set_acoustic_parameters)();
-
struct msm_snd_endpoint *ept;
- acoustic = ::dlopen("/system/lib/libhtc_acoustic.so", RTLD_NOW);
- if (acoustic == NULL ) {
- LOGE;
- /* this is not really an error on non-htc devices... /
- mNumSndEndpoints = 0;
- mInit = true;
- return;
- } set_acoustic_parameters = (int ()(void))::dlsym(acoustic, "set_acoustic_parameters");
- if ((set_acoustic_parameters) == 0 ) {
- LOGE");
- return;
- } int rc = set_acoustic_parameters();
- if (rc < 0) {
- LOGE;// return; } snd_get_num = (int ()(void))::dlsym(acoustic, "snd_get_num_endpoints");
- if ((*snd_get_num) == 0 ) {
- LOGE");// return; }
+ LOGI;
+ mInit = true;
mNumSndEndpoints = snd_get_num();
LOGD("mNumSndEndpoints = %d", mNumSndEndpoints);
@ -102,11 +142,6
@ AudioHardware::AudioHardware() :
mInit = true;
LOGV("constructed %d SND endpoints)", mNumSndEndpoints);
ept = mSndEndpoints;
- snd_get_endpoint = (int (*)(int, msm_snd_endpoint *))::dlsym(acoustic, "snd_get_endpoint");
- if ((*snd_get_endpoint) == 0 ) {
- LOGE("Could not open snd_get_endpoint()");
- return;
- }
for (int cnt = 0; cnt < mNumSndEndpoints; cnt++, ept++) {
ept->id = cnt;
@ -488,17 +523,14
@ status_t AudioHardware::doAudioRouteOrMute(uint32_t device)
mMode != AudioSystem::MODE_IN_CALL, mMicMute);
}
status_t AudioHardware::doRouting()
{
- /* currently this code doesn't work without the htc libacoustic */
- if (!acoustic)
- return 0;
@ -576,11 +608,7
@ status_t AudioHardware::doRouting()
if (sndDevice != 1 && sndDevice != mCurSndDevice) {
ret = doAudioRouteOrMute(sndDevice);
if ((*msm72xx_enable_audpp) == 0 ) {
- LOGE("Could not open msm72xx_enable_audpp()");
- } else {
- msm72xx_enable_audpp(audProcess);
- }
+ msm72xx_enable_audpp(audProcess);
mCurSndDevice = sndDevice;
}
}}}
Note several things:
Re-using source code === Ril === * vilvord ril * openmoko (android on freerunner) ril
Source organization and commit accessThen create a directory, not under the replicant-2.2 directory that will contain your repositories:
{{{
mkdir repo
cd repo
}}}
and clone the source:
{{{
git clone git://github.com/CyanogenMod/android_device_htc_buzz.git
cd android_device_htc_buzz
}}}
apply the previous patch:
{{{
git apply path/to/git_diff.patch
}}}
commit locally the result:
{{{
git commit -s
}}}
Note that the commit message should have the following format:
The first line should be a summary
Followed by a linebreak
And then the details explaining the commit
If you made an error writing the commit message do
{{{
git commit --amend
}}}
TODO: complete for sending the git patch(git format-patch -1,git send-email)
==== Pushing to replicant ====
TODO: git remote add+git push