Miracast For Realtek WiFi
Miracast For Realtek WiFi
1. Introduction
Wi-Fi Alliance had announced the Miracast (Wi-Fi Display developed by Wi-Fi
Alliace – WFD) in May 2012 and the specification had been finalized in the end of
August 2012.
This document is not prepared for Android 4.2(and newer), They had their own
structure implementing Miracast.
This picture is captured from the Miracast specification. The parts surrounded by Blue
line should be provided/implemented by system vendor. Realtek will provide the parts
surrounded by Red line.
The Realtek software package had included the Wi-Fi driver and wpa_supplicant for
Miracast feature. The Wi-Fi driver and wpa_supplicant had been modified to support
Miracast on Andorid 4.0(ICS) / Android 4.1 (Jelly Bean) platforms or Linux
embedded systems. This document will provide the guideline how to enable/process
the Miracast these platforms by using the Realtek Wi-Fi solution.
Please also make sure the following flags had been defined and enabled as well in
the .config file for Wi-Fi Direct functionality.
CONFIG_DRIVER_NL80211=y
CONFIG_CTRL_IFACE=y
CONFIG_P2P=y
CONFIG_AP=y
CONFIG_WPS=y
CONFIG_WPS2=y
P.S.: For wpa_supplicant_8_jb_4.2_rtw_rxxxx.xxxxxxxx.tar.gz, please disable
CONFIG_WIFI_DISPLAY because it’s for Android 4.2 (and newer) usage. That is:
# CONFIG_WIFI_DISPLAY=y
After making sure all the necessary flags are defined and enabled, please re-compile
it.
If a wpa_supplicant already exists on your system with supporting the Wi-Fi Direct
functionality, you can search the “CONFIG_WFD” keyword in this released
wpa_supplicant and merge it into your wpa_suppliacnt as well.
2.2 Setting configuration file for wpa_supplicant ( WFD.conf file of Realtek software
package )
In the setting configuration file, it can contain the Miracast pre-values when the
wpa_supplicant is initialized.
The “device_name” is the human-readable string. Other Miracast device will show
this name on its application/utility for your Miracast device.
The “wfd_tcpport” is the port number used by your Miracast RTSP engine. The
default value is 554.
The “wfd_device_type” will specify the type of your Miracast device. If your
Miracast device is the Source device, please assign 0 to it. If your Miracast device is
Sink device, please assign 1 to it.
The wpa_cli will show up all the devices which support Wi-Fi Direct and Miracast.
In this example, three P2P devices are discovered. However, only one P2P device with
00:e0:4c:00:d1:f4 MAC address supports the Miracast feature. If the P2P device
supports the Miracast feature, the “wfd_session_avail”, “wfd_rtsp_ctrlport”,
“wfd_device” will appear in its attribute information.
The “wfd_session_avail” will show up the status of WFD session of this P2P device.
“wfd_session_avail:1” means this P2P device is ready for Miracast session.
“wfd_session_avail:0” means the Miracast session of this P2P device is occupied and
is not able to start the Miracast now.
The “wfd_rtsp_ctrlport” means the port number of RTSP engine is using now. A
Miracast Sink device should fetch this port number and connect to it after having the
successful P2P connection.
The “wfd_device” means the Miracast device type of this P2P device.
“wfd_device=0” means this P2P device is Miracast Source device. “wfd_device=1”
means this P2P device is Miracast Sink device.
We can use the “mode” information to know this Miracast device is P2P GO or P2P
client. If this Miracast device is P2P client, the “mode” element will be “station”. If
this device is P2P GO, the “mode” will be “P2P GO”.
When the “wpa_state” element is “COMPLETED”, it means the P2P connection had
been established successfully.
For the Miracast Sink device, it is necessary to know the IP address of Miracast
Source device. After that, the Miracast Sink device is just able to connect to Miracast
Source device to start the RTSP handshake.
Unfortunately, there is no a common way to get peer’s IP address on all systems. For
Linux system, it is possible to use the different DHCP client/DHCP Server
applications. But there might be different ways to get the IP address for the peer’s
Miracast device.
On other Android systems, we can use the showlease command to know peer Miracast
device if this Miracast device is P2P client.
#> showlease wlan0 // Assume we had a P2P connection on wlan0
Addr: 192.168.10.113
Net: 255.255.255.0
Leasetime: 604800
Renew: 0
Rebind: 0
Server: 192.168.10.10
If this Miracast device is P2P client, the IP address for Miracast Source device is
192.168.10.10 in this example. We can also check the
“WifiP2pInfo.groupOwnerAddress” to know the IP address for Miracast source
device.
For the Miracast Sink device, it can start the RTSP handshake after getting the IP
address of Miracast Source device and control port number ( by using the scan results
of p2p_find).
For the Miracast Source device, it should just launch the RTSP server and wait for the
connection on control port.