guruevi
Posts: 7
Joined: Fri Aug 09, 2013 2:53 pm

tvservice -s outputs and states

Fri Aug 09, 2013 3:12 pm

Hi,

I was wondering whether there was any documentation or source code surrounding the tvservice (HDMI status) utility. I am attempting to decode the states that it returns when the TV is off, standby, on, ... I have tested on 2 TV's so far and get a number of codes:

0x40001
Not initialized and HDMI cable is disconnected (booting without a cable)

0x40002
Not initialized but HDMI cable is connected (plugged in after boot)

0x120002
Standby (when RPi turns off the HDMI channel using tvservice -o)

0x120005
Wire disconnected (after initialization)

0x120016
Active (meaning the Pi is on the active TV input right now)

A Vizio TV when using tvservice -o and then tvservice -p commands will eventually show:
0x12001a - Active?
and then switch to 0x12000a - Inactive? when I change the input on the TV but does not report when it turns active again.

Can anyone help me and see what their TV reports in different states using the tvservice utility (execute tvservice -s everytime you change a state should be in the path, if not, /opt/vc/bin)

GrandAdmiral
Posts: 21
Joined: Thu Apr 18, 2013 2:34 pm

Re: tvservice -s outputs and states

Fri Aug 09, 2013 7:43 pm

What a coincidence, I was also looking at tvservice today. Vizio TV and I see the following:

0x12000a during normal mode (RPi is booted, TV is displaying the command prompt)

tvservice -o turns off the display

0x120002 with nothing displayed on the TV

tvservice -p turns on the display, but I don't see the command prompt

0x12001A with nothing displayed on the TV

tvservice --explicit="CEA 16" tries to turn on the display, but explicitly sets the HDMI mode I was using previously

0x12001A with nothing displayed on the TV

Removed the HDMI cable from the RPi

0x120009

Reconnected the HDMI cable to the RPi

0x12000A, but still no command prompt on the display. Same status code after a reboot of the system, but now I see the command prompt on the display again. I'm not sure why I can't restart the display after using tvservice to turn it off. Is that the RPi's fault or the TV's fault? Does that work for you?

guruevi
Posts: 7
Joined: Fri Aug 09, 2013 2:53 pm

Re: tvservice -s outputs and states

Fri Aug 09, 2013 8:40 pm

Similar to yours except that when I use tvservice -p the image comes back. I am playing back video content the entire time (using a custom player) and using SSH to connect to the Pi and query the tvservice.

Funnily tvservice -o does not put the system in standby, it just blanks the display. To actually put the TV in standby, I have to issue a command using cec-client.

GrandAdmiral
Posts: 21
Joined: Thu Apr 18, 2013 2:34 pm

Re: tvservice -s outputs and states

Sun Aug 18, 2013 12:21 am

Yeah, I'm also connected to the Pi through SSH for the tvservice commands, but I'm just sitting on Raspbian's LXDE desktop. Maybe it would behave differently if I was playing some video content. I'll have to try that.

Using the cec-client is next on my list (at some point). If you've found some good resources, I'd love to know. I setup the client, but I didn't get very far with messing around with the commands. It seemed like they were kind of cryptic, but I didn't spend a lot of time looking at them.

Thanks!

User avatar
AndrewS
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
Contact: Website

Re: tvservice -s outputs and states

Mon Aug 26, 2013 2:52 pm

guruevi wrote:I was wondering whether there was any documentation or source code surrounding the tvservice (HDMI status) utility.
Dunno about documentation, but the source code is here https://github.com/raspberrypi/userland ... /tvservice if that helps?
I think you'll probably also want to look at http://elinux.org/RPi_VideoCore_APIs#vc_tvservice_.2A
and the various header files in https://github.com/raspberrypi/userland ... /vmcs_host

EDIT: digging into it a bit more, and looking at https://github.com/raspberrypi/userland ... dmi.h#L468 and https://github.com/raspberrypi/userland ... dtv.h#L122
your status values translate as follows:
0x40001 = VC_SDTV_NTSC, VC_HDMI_UNPLUGGED
0x40002 = VC_SDTV_NTSC, VC_HDMI_ATTACHED
0x120002 = VC_SDTV_ATTACHED, VC_SDTV_CP_INACTIVE, VC_HDMI_ATTACHED
0x120005 = VC_SDTV_ATTACHED, VC_SDTV_CP_INACTIVE, VC_HDMI_UNPLUGGED, VC_HDMI_DVI
0x120016 = VC_SDTV_ATTACHED, VC_SDTV_CP_INACTIVE, VC_HDMI_ATTACHED, VC_HDMI_DVI, VC_HDMI_HDCP_UNAUTH
0x12001a = VC_SDTV_ATTACHED, VC_SDTV_CP_INACTIVE, VC_HDMI_ATTACHED, VC_HDMI_HDMI, VC_HDMI_HDCP_UNAUTH
0x12000a = VC_SDTV_ATTACHED, VC_SDTV_CP_INACTIVE, VC_HDMI_ATTACHED, VC_HDMI_HDMI
0x120009 = VC_SDTV_ATTACHED, VC_SDTV_CP_INACTIVE, VC_HDMI_UNPLUGGED, VC_HDMI_HDMI

ds00424
Posts: 5
Joined: Mon Oct 21, 2013 2:19 pm

Re: tvservice -s outputs and states

Sat Sep 13, 2014 7:35 pm

I know this thread is a year old, but I am wondering if GrandAdmiral was able to switch modes and get the console to display? (or anyone else with a Vizio TV or similar issue).

My problem is similar. I have a Visio TV connected to my RPi via HDMI. Both are powered from a power strip. When I turn both on at the same time (via the power strip) the TV is in 720p mode and shows the console.

Code: Select all

[email protected] ~ $ tvservice -s
state 0x120016 [DVI CEA (4) RGB lim 16:9], 1280x720 @ 60Hz, progressive
When I change it to 1080p mode the TV shows it has changed to 1080p, but does not show the console - just a black screen.

Code: Select all

[email protected] ~ $ tvservice --explicit="CEA 16 HDMI"
Powering on HDMI with explicit settings (CEA mode 16)
Changing back to 720p, does change the TV mode, but still no console.

Code: Select all

[email protected] ~ $ tvservice --explicit="CEA 4 DVI"
Powering on HDMI with explicit settings (CEA mode 4)
[email protected] ~ $ tvservice -s
state 0x120016 [DVI CEA (4) RGB lim 16:9], 1280x720 @ 60Hz, progressive
At this point, if I reboot the RPi, leaving the TV powered, the TV changes to 1080p and shows the console login.

If I power both the RPi and TV down, turn on the TV first, then turn on the RPi, the TV comes up in 1080p and shows the console.


Any thoughts on how I can successfully change modes but still have the console displayed?

Thanks
ds00424

User avatar
rpdom
Posts: 12945
Joined: Sun May 06, 2012 5:17 am
Location: Ankh-Morpork

Re: tvservice -s outputs and states

Sat Sep 13, 2014 8:07 pm

When changing the resolution of the framebuffer device (console), you can use the fbset command to force a refresh of the screen and to change resolution.

First do a dummy sudo fbset -depth 8 to make it realise something has changed, then sudo fbset -g X Y X Y D where X and Y are the resolution of your screen, and D is the bits-per-pixel value you are using (probably 16 unless you have changed it).

So to set 1280x720, after the tvservice command you'd do

Code: Select all

fbset -depth 8
fbset -g 1280 720 1280 720 16
You need to give the X and Y values twice because the first pair set the physical display size and the second set the virtual display size.

GrandAdmiral
Posts: 21
Joined: Thu Apr 18, 2013 2:34 pm

Re: tvservice -s outputs and states

Sat Sep 13, 2014 9:20 pm

I know this thread is a year old, but I am wondering if GrandAdmiral was able to switch modes and get the console to display? (or anyone else with a Vizio TV or similar issue).
Unfortunately I wasn't able to get it working, but I also wasn't able to spend a lot of time on it after I posted my question. If you do figure it out, I'd like to know the answer.

ds00424
Posts: 5
Joined: Mon Oct 21, 2013 2:19 pm

Re: tvservice -s outputs and states

Sat Sep 13, 2014 9:35 pm

Wonderful!
yep that did it.

For the record, here is the start to finish events that work for me:
boot TV and RPi simultaneously. Rpi Boots, TV stays off.
Turn TV on, select correct input if needed (I am using cec-client here)
Console is in 720p
(Now if i only do the fbset sequence, the TV remains in 720p mode)

Code: Select all

tvservice --explicit="CEA 16 HDMI"   # sets the TV to 1080p
fbset -depth 8          # dummy fbset as rpdom advised
fbset -g 1920 1080 1920 1080 16
All is good and my code can proceed. Sweet.

Thanks much!

Return to “Advanced users”