5

To avoid this question being flagged as a duplicate, I have included a list of similar questions at the end of this post with an explanation about why my question is different. Please read these reasons before you flag this question as a duplicate!


I'm trying to work out how to get my Nexus 5, in portrait mode, to display on an external monitor, in portrait mode (connected via SlimPort/HDMI).

In landscape mode everything is fine:

Landscape mode, monitor on left, phone on right

However in portrait mode, the signal is still output as if it is meant to be displayed on a landscape screen, which doesn't work at all if the screen is in portrait mode:

Portait mode, monitors left and middle, phone on right

You can see here that in both landscape and portrait mode the phone is outputting the same 1920x1080 signal, except in portrait mode the screen content is being rotated by the phone's GPU and displayed as a 607x1080 image in the middle of the 1920x1080 screen. (It is not, as some people have suggested, outputting a 1080x1920 signal that the monitor is centering. You can verify this because changing the phone between landscape and portrait shows a nice rotation animation and the monitor does not lose sync as it would if the resolution changed.)

Since the phone, when in portrait mode, is rotating the picture sent to the external display, I want to disable this, so it is just output as-is with no rotation. This will of course appear wrong on a landscape monitor, but when you rotate that monitor into portrait mode it will be fine:

enter image description here

Is there any way to disable this rotation, so that an external display in portrait mode can display the phone's content when it too is in portrait mode?


Similar questions have been asked before, but none are after the same solution:

  • I cant get this to work. Does the accepted answer still work for you with Newer versions of android? If so, could you please exapand on the steps needed. Thank you – Uli Sep 16 '16 at 15:02
  • 1
    Yes I just tried it following the commands in the accepted answer with Android 6.0.1 and it works. Unfortunately the signal that is output is only 1280x1024 so it still does not display properly on my 1920x1200 display (the screen is rotated correctly into portrait mode but there are black bars on the left and right of the portrait screen.) As I mentioned in my comment on that answer, it only works if you are root, so I used the SSH Droid app to connect as root, then ran setprop persist... there so that I could see any error messages more clearly and be certain I was the root user. – Malvineous Sep 16 '16 at 23:17
5

Try these instructions, using a computer with adb installed and your phone connected:

Android Jelly Bean (4.2) locks HDMI rotation by default. You can unlock by the instruction of this commit.

  1. Add special mirroring modes for demonstration purposes.

  2. Assume rotation of HDMI display is portrait.

    adb shell setprop persist.demo.hdmirotation portrait
    
  3. Don't lock rotation while HDMI is plugged in.

    adb shell setprop persist.demo.hdmirotationlock false
    
  4. Hide secondary displays from apps but continue mirroring to them.

    adb shell setprop persist.demo.singledisplay true
    

Source: https://community.freescale.com/docs/DOC-97740

  • 2
    It worked! The change moved around a bit but it still exists in the latest Marshmallow code (see here) however you need to be root in order to add the persist.demo.hdmirotation property. If you aren't the root user, you'll get an error when you try to set the property. Only drawback is the output signal is 1280x1024 instead of 1920x1200, but at least it's rotated! Next step is to figure out how to change resolution! – Malvineous Mar 8 '16 at 11:38
  • I cant get this to work. after sending the commands over adb android still assumes the monitor is in landscape orientation. Could you provide more step by step instructions please (also I didnt understand step 1). Or is this no longer working with android 6? – Uli Sep 16 '16 at 14:39
  • Try running the shell command getprop | grep demo to confirm that the values you have set have been stored correctly. – Malvineous Sep 16 '16 at 23:19
  • Not work for me on oneplus5 with Android 8.1. I have check the code, all version(6.0~8.1) have persist.demo.hdmirotation Also try on LG G3, Nexus, all of these devices did not work. – Aris Lee Sep 19 '18 at 16:42
1

I know this is an old post but I was just dealing with a similar issue but trying to cast the screen of a Pixel 2 device to a portrait screen and was running into a lot of issues. The main problem seems to be that Pixel 2 and 3 do not seem to support HDMI output so these properties do not solve the issue.

However, I was able to figure this out by following the link Malvineous posted in a comment above. Just below the code dealing with setting persist.demo.hdmirotation there is another setting called persist.demo.remoterotation as well as one called persist.demo.rotationlock. These were the key to getting a phone to cast in portrait mode to the screen. These settings seem to exist in both 8.0 and 9.0 versions of Android, though I downgraded my Pixel 2 to 8.0 in the process of trying to figure this out and have not tested on 9.0 yet.

To get to this point took several steps which are outlined below.

  1. You need to unlock and root your phone (I used MagiskManager to help root and I found this guide very useful as it explains a little more in detail exactly what to do for those like me who had not done this before).
  2. Using adb tool start the adb shell on your connected and rooted device adb shell
  3. Activate superuser by entering su in shell (for me this had the additional step of going into MagiskManager and allowing SuperUser access to the shell).
  4. Enter the following lines into the shell to create and set these properites:
    setprop persist.demo.remoterotation portrait
    setprop persist.demo.rotationlock false
    

Once that was set, I cast my Pixel 2's screen to a chromecast device and it was in the desired portrait orientation. I hope this helps anyone in the future trying to figure this out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.