UBports Robot Logo UBports Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Sony Xperia X (suzu/F5121 & F5122)

    Scheduled Pinned Locked Moved Sony Xperia X (F5121 & F5122)
    324 Posts 63 Posters 235.7k Views 15 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
      Reply
      • Reply as topic
      Log in to reply
      This topic has been deleted. Only users with topic management privileges can see it.
      • c4pp4C Offline
        c4pp4 @fredldotme
        last edited by c4pp4

        @fredldotme
        Thank you. Unfortunately changing touch.pa has no effect on quality.

        1 Reply Last reply Reply Quote 0
        • c4pp4C Offline
          c4pp4 @fredldotme
          last edited by

          @fredldotme
          /etc/pulse/daemon.conf

          default-sample-rate = 44100
          alternate-sample-rate = 48000
          

          /etc/pulse/touch.pa

          .ifexists module-droid-card-24.so
          load-module module-droid-card-24 rate=44100 quirks=+unload_call_exit
          .endif
          

          syslog

          May 15 03:06:10 ubuntu-phablet pulseaudio[6939]: [pulseaudio] droid-util.c: Requested sample rate 44100 but got 48000 instead.
          May 15 03:06:10 ubuntu-phablet pulseaudio[6939]: [pulseaudio] sink.c: Default and alternate sample rates are the same.
          

          It always falls to 48kHz. It's weird.

          1 Reply Last reply Reply Quote 0
          • c4pp4C Offline
            c4pp4 @fredldotme
            last edited by

            This post is deleted!
            1 Reply Last reply Reply Quote 0
            • J Offline
              jro @c4pp4
              last edited by

              @c4pp4 It is strange though, that there is no documented way of getting the ubports version of android to use rootfs-overlay, just as the snap version does. Indeed, repacking the squshfs isn't such a big deal (although I wouldn't have known of the parameters you used, but still, just dropping a file into the overlay directory tree would make things so much easier!
              BTW, the sound that you get from android apps after completing this step is quite choppy, not really suitable for real use, more a proof of concept.

              1 Reply Last reply Reply Quote 0
              • J Offline
                jro @fredldotme
                last edited by jro

                @fredldotme said in Sony Xperia X (suzu/F5121 & F5122):

                @c4pp4 nice catch!

                What you can do to test small modifications to the Halium portion (where this file is from):

                • Reboot into recovery
                • Connect to the device via ADB
                • Mount the Halium system image: mount /system/var/lib/lxc/android/system.img /tmp

                There is no directory /system/var/lib in recovery mode, I also cannot find a system.img anywhere. Has this changed recently?

                • Edit the Halium override file to your liking: nano /tmp/halium/etc/pulse/touch.pa

                Wouldn't this be the file /system/halium/etc/pulse/touch.pa?

                EDIT: losetup -a says that /dev/loop0 is pointing to /halium-system/var/lib/lxc/android/system.img, yet there is no directory /halium-system. How can I access it?

                c4pp4C 1 Reply Last reply Reply Quote 0
                • H Offline
                  Hris @eichenbast
                  last edited by

                  This post is deleted!
                  1 Reply Last reply Reply Quote 0
                  • L Offline
                    Linux Klaus
                    last edited by

                    @fredldotme thank you so much for your awesome work. I just flashed the port a few days ago and everything is working super smooth.

                    I followed during the installation process your instructions and of @christophe14 (post 160). It helped me a lot.

                    The ubports installer caused a lot of trouble during the installation. I got a lot of error messages (they are already on github). The biggest problem for me was for some reason to boot into fastboot mode. It took me easily 40 attempts. Don't know why. For some reason the ubports installer also did not recognised the device (all the necessary drivers were installed. Switched over to the installer on fedora and did not had any problems.

                    Keep up the great work. I am amzed by this wonderful community and what you all have already achieved.

                    1 Reply Last reply Reply Quote 0
                    • c4pp4C Offline
                      c4pp4 @jro
                      last edited by

                      @jro
                      What is the output of

                      adb shell ls
                      

                      when the device is connected in recovery mode?

                      1 Reply Last reply Reply Quote 0
                      • c4pp4C Offline
                        c4pp4
                        last edited by

                        Some audio tweak:

                        • boot device into recovery

                        • mount system.img:

                        adb shell mount /system/var/lib/lxc/android/system.img /tmp
                        
                        • when playing 44.1 kHz audio stream the sound is crackling, default sample rate is 48 kHz and I think the resampler is too slow, fix it using higher latency via deep buffer flag:
                        adb pull /tmp/etc/audio_policy.conf
                        sed -i '/AUDIO_OUTPUT_FLAG_PRIMARY/{s/FAST/DEEP_BUFFER/}' audio_policy.conf
                        adb push audio_policy.conf /tmp/etc
                        
                        • ringtone volume is too low, it's played via output-speaker+wired_headphone port, set appropriate acdb_id:
                        adb pull /tmp/etc/audio_platform_info.xml
                        sed -i '/Custom mapping starts here/a \        <device name="SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES" acdb_id="799"/>' audio_platform_info.xml
                        adb push audio_platform_info.xml /tmp/etc
                        
                        • sound is distorted when max volume is used, correct max volume:
                        adb pull /tmp/etc/mixer_paths.xml
                        sed -i -e '/RX7 Digital Volume/{s/92/86/}' -e '/RX8 Digital Volume/{s/92/86/}' mixer_paths.xml
                        adb push mixer_paths.xml /tmp/etc
                        
                        • umount system.img:
                        adb shell umount /tmp
                        
                        • reboot the device
                        flohackF 1 Reply Last reply Reply Quote 0
                        • flohackF Offline
                          flohack @c4pp4
                          last edited by

                          @c4pp4 Wonderful, aber you able to integrate this permanently into the system image with a PR on Github? Your solution is too complex to apply and also will be overwritten by an update πŸ™‚

                          My languages: πŸ‡¦πŸ‡Ή πŸ‡©πŸ‡ͺ πŸ‡¬πŸ‡§ πŸ‡ΊπŸ‡Έ

                          1 Reply Last reply Reply Quote 0
                          • fredldotmeF Offline
                            fredldotme
                            last edited by

                            Yeah, those changes presented as a PR would be highly appreciated! I'm currently occupied with a lot of other things, so I probably can't do it myself in the short term. The files you're modifying are probably in the suzu and loire repos on GitHub linked in the top post.

                            1 Reply Last reply Reply Quote 0
                            • fredldotmeF Offline
                              fredldotme
                              last edited by

                              Thanks again to @c4pp4 for preparing those changes as a pull request, the changes will land within the next two days. πŸ™‚

                              c4pp4C 1 Reply Last reply Reply Quote 0
                              • c4pp4C Offline
                                c4pp4 @fredldotme
                                last edited by

                                @fredldotme
                                No problem πŸ™‚

                                I'm trying to achieve 44.1 kHz as the default rate or find out why is resampler too slow. I'm not sure if it's pulseaudio server, droid module or qcom driver related or something else.

                                1 Reply Last reply Reply Quote 0
                                • c4pp4C Offline
                                  c4pp4
                                  last edited by c4pp4

                                  @fredldotme
                                  I think I find out why it's always using 48 kHz. It's related to qcom/audio/hal. According to this commit https://github.com/fredldotme/device-sony-common/commit/b3235f337a371d7746fe591e3adcaca99c90dc4f we are using qcom/audio/default/hal/audio_hw.c where adev_open_output_stream function is always assigning 48 kHz rate regardless of what we configure in audio_policy.conf/touch.pa:

                                  3065       out->sample_rate = out->config.rate
                                  

                                  newer version contains:

                                  5295       if (config->sample_rate == 0) {
                                  5296                   out->sample_rate = out->config.rate;
                                  5297               } else {
                                  5298                   out->sample_rate = config->sample_rate;
                                  5299       }
                                  

                                  Is there a chance to test patched version?

                                  fredldotmeF 1 Reply Last reply Reply Quote 0
                                  • G Offline
                                    Giampy
                                    last edited by

                                    This post is deleted!
                                    1 Reply Last reply Reply Quote 0
                                    • fredldotmeF Offline
                                      fredldotme @c4pp4
                                      last edited by

                                      @c4pp4 you could build your own Halium image and test it that way. The build instructions are here: https://github.com/Halium/projectmanagement/issues/98

                                      Just build the systemimage, run simg2img, e2fsck and resize2fs on it and put it in /system/var/lib/lxc/android/system.img.

                                      c4pp4C 2 Replies Last reply Reply Quote 0
                                      • c4pp4C Offline
                                        c4pp4 @fredldotme
                                        last edited by

                                        @fredldotme
                                        Thank you!

                                        1 Reply Last reply Reply Quote 0
                                        • c4pp4C Offline
                                          c4pp4 @fredldotme
                                          last edited by c4pp4

                                          @fredldotme
                                          I've patched it and successfully built and tested.

                                          patch:

                                          diff -Nur a/hardware/qcom/audio/hal/audio_hw.c b/hardware/qcom/audio/hal/audio_hw.c
                                          --- a/hardware/qcom/audio/hal/audio_hw.c	2020-06-03 09:11:31.406960000 +0200
                                          +++ b/hardware/qcom/audio/hal/audio_hw.c	2020-06-03 23:34:16.000000000 +0200
                                          @@ -3033,6 +3033,8 @@
                                                           out->format = audio_format_from_pcm_format(out->config.format);
                                                       }
                                                   }
                                          +        if (config->sample_rate != 0)
                                          +            out->config.rate = config->sample_rate;
                                                   out->sample_rate = out->config.rate;
                                               }
                                               ALOGV("%s: Usecase(%s) config->format %#x  out->config.format %#x\n",
                                          

                                          adb shell pacmd list-sinks:

                                          2 sink(s) available.
                                            * index: 0
                                          	name: <sink.primary>
                                          	driver: <module-droid-card.c>
                                          	flags: HARDWARE DECIBEL_VOLUME LATENCY 
                                          	state: SUSPENDED
                                          	suspend cause: IDLE 
                                          	priority: 9000
                                          	volume: front-left: 65536 / 100% / 0,00 dB,   front-right: 65536 / 100% / 0,00 dB
                                          	        balance 0,00
                                          	base volume: 65536 / 100% / 0,00 dB
                                          	volume steps: 65537
                                          	muted: no
                                          	current latency: 0,00 ms
                                          	max request: 0 KiB
                                          	max rewind: 0 KiB
                                          	monitor source: 0
                                          	sample spec: s16le 2ch 44100Hz
                                          	channel map: front-left,front-right
                                          	             Stereo
                                          	used by: 0
                                          	linked by: 1
                                          	fixed latency: 10,00 ms
                                          	card: 0 <droid_card.primary>
                                          	module: 4
                                          	properties:
                                          		device.description = "Droid sink primary"
                                          		device.class = "sound"
                                          		device.api = "droid-hal"
                                          		droid.flags = "AUDIO_OUTPUT_FLAG_PRIMARY|AUDIO_OUTPUT_FLAG_FAST"
                                          		droid.hw_module = "primary"
                                          		device.icon_name = "audio-card"
                                          		droid.output.primary = "true"
                                          		droid.output.low_latency = "true"
                                          		droid.output.media_latency = "true"
                                          	ports:
                                          		output-earpiece: Output to earpiece (priority 200, latency offset 0 usec, available: yes)
                                          			properties:
                                          				
                                          		output-speaker: Output to speaker (priority 300, latency offset 0 usec, available: yes)
                                          			properties:
                                          				
                                          		output-wired_headset: Output to wired headset (priority 100, latency offset 0 usec, available: no)
                                          			properties:
                                          				
                                          		output-wired_headphone: Output to wired headphone (priority 100, latency offset 0 usec, available: no)
                                          			properties:
                                          				
                                          		output-bluetooth_sco: Output to bluetooth sco (priority 100, latency offset 0 usec, available: yes)
                                          			properties:
                                          				
                                          		output-sco_headset: Output to sco headset (priority 100, latency offset 0 usec, available: yes)
                                          			properties:
                                          				
                                          		output-sco_carkit: Output to sco carkit (priority 100, latency offset 0 usec, available: yes)
                                          			properties:
                                          				
                                          		output-aux_digital: Output to aux digital (priority 100, latency offset 0 usec, available: yes)
                                          			properties:
                                          				
                                          		output-speaker+wired_headphone: Output to speaker+wired headphone (priority 100, latency offset 0 usec, available: no)
                                          			properties:
                                          				
                                          		output-parking: Parking port (priority 50, latency offset 0 usec, available: yes)
                                          			properties:
                                          				
                                          	active port: <output-speaker>
                                          
                                          fredldotmeF 1 Reply Last reply Reply Quote 0
                                          • fredldotmeF Offline
                                            fredldotme @c4pp4
                                            last edited by fredldotme

                                            @c4pp4 looks sane at first glance. It would be interesting to know how it behaves with different sample settings provided through the touch.pa file. Does it now allow forcing the sample rate that way? In that case even better, but it looks like it should work on all Sony devices.

                                            Would you like to prepare a PR for it, so it has your name in the commit history? πŸ™‚

                                            c4pp4C 1 Reply Last reply Reply Quote 0
                                            • c4pp4C Offline
                                              c4pp4 @fredldotme
                                              last edited by c4pp4

                                              @fredldotme
                                              It should work on all devices using 'hardware/qcom/audio'. Now it takes default settings from pulseaudio (44.100 kHz) if it's not specified through /etc/pulse/daemon.conf. You can override it changing 'default-sample-rate' parameter. You can change the sampling rate through /etc/pulse/touch.pa as well using 'rate', 'sink_rate' or source_rate' parameter when loading module-droid-card-24.

                                              fredldotmeF 1 Reply Last reply Reply Quote 0
                                              • First post
                                                Last post