APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.glass.ui.monocle

pack-priv Class EPDFrameBuffer

extends Object
Class Inheritance
Imports
com.sun.glass.ui.monocle.EPDSystem.FbVarScreenInfo, .EPDSystem.IntStructure, .EPDSystem.MxcfbUpdateData, .EPDSystem.MxcfbWaveformModes, com.sun.javafx.logging.PlatformLogger, .PlatformLogger.Level, com.sun.javafx.util.Logging, java.io.IOException, java.nio.ByteBuffer, java.text.MessageFormat

Represents the standard Linux frame buffer device interface plus the custom extensions to that interface provided by the Electrophoretic Display Controller (EPDC) frame buffer driver.

The Linux frame buffer device interface is documented in The Frame Buffer Device API found in the Ubuntu package called linux-doc (see /usr/share/doc/linux-doc/fb/api.txt.gz).

The EPDC frame buffer driver extensions are documented in the i.MX Linux Reference Manual available on the NXP website (registration required). On the NXP home page, click Products, ARM Processors, i.MX Application Processors, and then i.MX 6 Processors, for example. Select the i.MX6SLL Product in the chart; then click the Documentation tab. Look for a download with a label for Linux documents, like L4.1.15_2.1.0_LINUX_DOCS, under the Supporting Information section. After downloading and expanding the archive, the reference manual is found in the doc directory as the file i.MX_Linux_Reference_Manual.pdf.

Field Summary

Modifier and TypeField and Description
private static final int
BITS_TO_BYTES

The arithmetic right shift value to convert a bit depth to a byte depth.

private final int
private final int
private final int
private final EPDSystem
private static final int
ENOTTY

Linux system error: ENOTTY 25 Inappropriate ioctl for device.

private final long
private int
private final PlatformLogger
private static final int
POWERDOWN_DELAY

The delay in milliseconds between the completion of all updates in the EPDC driver and when the driver powers down the EPDC and display power supplies.

private final EPDSettings
private final EPDSystem.MxcfbUpdateData
private final LinuxSystem
private final EPDSystem.MxcfbUpdateData
private int
private final int
private final int
private final int
private final int
private final int
private final int

Constructor Summary

AccessConstructor and Description
pack-priv
EPDFrameBuffer(String
the frame buffer device path, such as /dev/fb0
fbPath
)

Creates a new EPDFrameBuffer for the given frame buffer device.

Method Summary

Modifier and TypeMethod and Description
pack-priv void
clear()

Clears the display panel.

pack-priv void
close()

Closes the Linux frame buffer device.

private EPDSystem.MxcfbUpdateData

Returns:

the default update data with all fields set but the update marker
createDefaultUpdate
(int
the width of the update region
width
,
int
the height of the update region
height
)

Creates the default update data with values from the EPD system properties, setting all fields except for the update marker.

pack-priv int

Returns:

the color depth in bits per pixel
getBitDepth
()

Gets the frame buffer color depth in bits per pixel.

pack-priv int

Returns:

the offset in bytes
getByteOffset
()

Gets the number of bytes from the beginning of the frame buffer to the start of its visible resolution.

pack-priv int

Returns:

the height in pixels
getHeight
()

Gets the frame buffer height in pixels.

pack-priv ByteBuffer

Returns:

a byte buffer containing the mapping of the Linux frame buffer device if successful; otherwise null
getMappedBuffer
()

Creates a new mapping of the Linux frame buffer device into memory.

pack-priv long

Returns:

the frame buffer device file descriptor
getNativeHandle
()

Gets the native handle to the Linux frame buffer device.

pack-priv ByteBuffer

Returns:

a 32-bit pixel buffer matching the resolution of the frame buffer
getOffscreenBuffer
()

Creates an off-screen byte buffer equal in resolution to the virtual resolution of the frame buffer, but with 32 bits per pixel.

private int

Returns:

the delay in milliseconds
getPowerdownDelay
()

Gets the current power-down delay from the EPDC driver.

private void
getScreenInfo(EPDSystem.FbVarScreenInfo
the object representing the variable screen information
screen
)

Gets the variable screen information of the frame buffer.

pack-priv int

Returns:

the width in pixels
getWidth
()

Gets the frame buffer width in pixels.

pack-priv void
init()

Initializes the EPDC frame buffer device, setting the update scheme to EPDSystem#UPDATE_SCHEME_SNAPSHOT.

private void
logScreenInfo(EPDSystem.FbVarScreenInfo
the object representing the variable screen information
screen
)

Logs the variable screen information of the frame buffer, depending on the logging level.

pack-priv void
releaseMappedBuffer(ByteBuffer
the byte buffer containing the mapping of the Linux frame buffer device
buffer
)

Deletes the mapping of the Linux frame buffer device.

private int

Returns:

the marker to identify this update in a subsequence call to waitForUpdateComplete
sendUpdate
(int updateMode, int waveformMode, int flags)

Requests the entire visible region of the frame buffer to be updated to the display.

private int

Returns:

the marker to identify this update in a subsequence call to waitForUpdateComplete
sendUpdate
(EPDSystem.MxcfbUpdateData
the data describing the update; the waveform mode and update marker are overwritten
update
,
int
the waveform mode for this update
waveformMode
)

Requests an update to the display, allowing for the reuse of the update data object.

private void
setAutoUpdateMode(int mode)

Selects between automatic and region update mode.

private void
setPowerdownDelay(int
the delay in milliseconds
delay
)

Sets the delay between the completion of all updates in the driver and when the driver should power down the EPDC and display power supplies.

private void
setScreenInfo(EPDSystem.FbVarScreenInfo
the object representing the variable screen information
screen
)

Sets the variable screen information of the frame buffer.

private void
setTemperature(int
the temperature in degrees Celsius
temp
)

Sets the temperature to be used by the EPDC driver in subsequent panel updates.

private void
setUpdateScheme(int scheme)

Selects a scheme for the flow of updates within the driver.

private void
setWaveformModes(int
the initialization mode for clearing the screen to all white
init
,
int
the direct update mode for changing any gray values to either all black or all white
du
,
int
the mode for 4-level (2-bit) grayscale images and text
gc4
,
int
the mode for 8-level (3-bit) grayscale images and text
gc8
,
int
the mode for 16-level (4-bit) grayscale images and text
gc16
,
int
the mode for 32-level (5-bit) grayscale images and text
gc32
)

Defines a mapping for common waveform modes.

pack-priv void
sync()

Sends the updated contents of the Linux frame buffer to the EPDC driver, optionally synchronizing with the driver by first waiting for the previous update to complete.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

private void
waitForUpdateComplete(int
the marker to identify a particular update, returned by sendUpdate(MxcfbUpdateData, int)
marker
)

Blocks and waits for a previous update request to complete.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

BITS_TO_BYTESback to summary
private static final int BITS_TO_BYTES

The arithmetic right shift value to convert a bit depth to a byte depth.

bitsPerPixelback to summary
private final int bitsPerPixel
byteOffsetback to summary
private final int byteOffset
bytesPerPixelback to summary
private final int bytesPerPixel
driverback to summary
private final EPDSystem driver
ENOTTYback to summary
private static final int ENOTTY

Linux system error: ENOTTY 25 Inappropriate ioctl for device.

fdback to summary
private final long fd
lastMarkerback to summary
private int lastMarker
loggerback to summary
private final PlatformLogger logger
POWERDOWN_DELAYback to summary
private static final int POWERDOWN_DELAY

The delay in milliseconds between the completion of all updates in the EPDC driver and when the driver powers down the EPDC and display power supplies.

settingsback to summary
private final EPDSettings settings
syncUpdateback to summary
private final EPDSystem.MxcfbUpdateData syncUpdate
systemback to summary
private final LinuxSystem system
updateDataback to summary
private final EPDSystem.MxcfbUpdateData updateData
updateMarkerback to summary
private int updateMarker
xoffsetback to summary
private final int xoffset
xresback to summary
private final int xres
xresVirtualback to summary
private final int xresVirtual
yoffsetback to summary
private final int yoffset
yresback to summary
private final int yres
yresVirtualback to summary
private final int yresVirtual

Constructor Detail

EPDFrameBufferback to summary
pack-priv EPDFrameBuffer(String fbPath) throws IOException

Creates a new EPDFrameBuffer for the given frame buffer device. The geometry of the Linux frame buffer is shown below for various color depths and rotations on a sample system, as printed by the fbset command. The first three are for landscape mode, while the last three are for portrait.

geometry 800 600 800 640 32 (line length: 3200)
geometry 800 600 800 1280 16 (line length: 1600)
geometry 800 600 800 1280 8 (line length: 800)

geometry 600 800 608 896 32 (line length: 2432)
geometry 600 800 608 1792 16 (line length: 1216)
geometry 600 800 608 1792 8 (line length: 608)

Implementation Note

MonocleApplication creates a Screen which requires that the width be set to xresVirtual even though only the first xres pixels of each row are visible. The EPDC driver supports panning only in the y-direction, so it is not possible to center the visible resolution horizontally when these values differ. The JavaFX application should be left-aligned in this case and ignore the few extra pixels on the right of its screen.

Parameters
fbPath:String

the frame buffer device path, such as /dev/fb0

Exceptions
IOException:
if an error occurs when opening the frame buffer device or when getting or setting the frame buffer configuration
IllegalArgumentException:
if the EPD settings specify an unsupported color depth

Method Detail

clearback to summary
pack-priv void clear()

Clears the display panel. The visible frame buffer should be cleared with zeros when called. This method sends two direct updates (all black followed by all white) to refresh the screen and clear any ghosting effects, and returns when both updates are complete.

This method is not thread safe, but it is invoked only once from the Event Thread during initialization.

closeback to summary
pack-priv void close()

Closes the Linux frame buffer device.

createDefaultUpdateback to summary
private EPDSystem.MxcfbUpdateData createDefaultUpdate(int width, int height)

Creates the default update data with values from the EPD system properties, setting all fields except for the update marker. Reusing the update data object avoids creating a new one for each update request.

Implementation Note

An update mode of EPDSystem#UPDATE_MODE_FULL would make the EPDSettings#NO_WAIT system property useless by changing all non-colliding updates into colliding ones, so this method sets the default update mode to EPDSystem#UPDATE_MODE_PARTIAL.

Parameters
width:int

the width of the update region

height:int

the height of the update region

Returns:EPDSystem.MxcfbUpdateData

the default update data with all fields set but the update marker

getBitDepthback to summary
pack-priv int getBitDepth()

Gets the frame buffer color depth in bits per pixel.

Returns:int

the color depth in bits per pixel

getByteOffsetback to summary
pack-priv int getByteOffset()

Gets the number of bytes from the beginning of the frame buffer to the start of its visible resolution.

Returns:int

the offset in bytes

getHeightback to summary
pack-priv int getHeight()

Gets the frame buffer height in pixels.

Returns:int

the height in pixels

getMappedBufferback to summary
pack-priv ByteBuffer getMappedBuffer()

Creates a new mapping of the Linux frame buffer device into memory.

Implementation Note

The virtual y-resolution reported by the device driver can be wrong, as shown by the following example on the Kobo Glo HD Model N437 which reports 2,304 pixels when the correct value is 1,152 pixels (6,782,976 / 5,888). Therefore, this method cannot use the frame buffer virtual resolution to calculate its size.

$ sudo fbset -i

mode "1448x1072-46"
# D: 80.000 MHz, H: 50.188 kHz, V: 46.385 Hz
geometry 1448 1072 1472 2304 32
timings 12500 16 102 4 4 28 2
rgba 8/16,8/8,8/0,8/24
endmode

Frame buffer device information:
Name        : mxc_epdc_fb
Address     : 0x88000000
Size        : 6782976
Type        : PACKED PIXELS
Visual      : TRUECOLOR
XPanStep    : 1
YPanStep    : 1
YWrapStep   : 0
LineLength  : 5888
Accelerator : No
Returns:ByteBuffer

a byte buffer containing the mapping of the Linux frame buffer device if successful; otherwise null

getNativeHandleback to summary
pack-priv long getNativeHandle()

Gets the native handle to the Linux frame buffer device.

Returns:long

the frame buffer device file descriptor

getOffscreenBufferback to summary
pack-priv ByteBuffer getOffscreenBuffer()

Creates an off-screen byte buffer equal in resolution to the virtual resolution of the frame buffer, but with 32 bits per pixel.

Returns:ByteBuffer

a 32-bit pixel buffer matching the resolution of the frame buffer

getPowerdownDelayback to summary
private int getPowerdownDelay()

Gets the current power-down delay from the EPDC driver.

Returns:int

the delay in milliseconds

getScreenInfoback to summary
private void getScreenInfo(EPDSystem.FbVarScreenInfo screen) throws IOException

Gets the variable screen information of the frame buffer. Run the fbset command as root to print the screen information.

Parameters
screen:EPDSystem.FbVarScreenInfo

the object representing the variable screen information

Exceptions
IOException:
if an error occurs getting the information
getWidthback to summary
pack-priv int getWidth()

Gets the frame buffer width in pixels. See the notes for the constructor above.

Implementation Note

When using an 8-bit, unrotated, and uninverted frame buffer in the Y8 pixel format, the Kobo Clara HD Model N249 works only when this method returns the visible x-resolution (xres) instead of the normal virtual x-resolution (xresVirtual).

Returns:int

the width in pixels

initback to summary
pack-priv void init()

Initializes the EPDC frame buffer device, setting the update scheme to EPDSystem#UPDATE_SCHEME_SNAPSHOT.

logScreenInfoback to summary
private void logScreenInfo(EPDSystem.FbVarScreenInfo screen)

Logs the variable screen information of the frame buffer, depending on the logging level.

Parameters
screen:EPDSystem.FbVarScreenInfo

the object representing the variable screen information

releaseMappedBufferback to summary
pack-priv void releaseMappedBuffer(ByteBuffer buffer)

Deletes the mapping of the Linux frame buffer device.

Parameters
buffer:ByteBuffer

the byte buffer containing the mapping of the Linux frame buffer device

sendUpdateback to summary
private int sendUpdate(int updateMode, int waveformMode, int flags)

Requests the entire visible region of the frame buffer to be updated to the display.

Parameters
updateMode:int

the update mode, one of:

waveformMode:int

the waveform mode, one of:

flags:int

a bit mask composed of the following flag values:

Returns:int

the marker to identify this update in a subsequence call to waitForUpdateComplete

sendUpdateback to summary
private int sendUpdate(EPDSystem.MxcfbUpdateData update, int waveformMode)

Requests an update to the display, allowing for the reuse of the update data object. The waveform mode is reset because the update data could have been used in a previous update. In that case, the waveform mode may have been modified by the EPDC driver with the actual mode selected. The update marker is overwritten with the next sequential marker.

Parameters
update:EPDSystem.MxcfbUpdateData

the data describing the update; the waveform mode and update marker are overwritten

waveformMode:int

the waveform mode for this update

Returns:int

the marker to identify this update in a subsequence call to waitForUpdateComplete

setAutoUpdateModeback to summary
private void setAutoUpdateMode(int mode)

Selects between automatic and region update mode. In region update mode, updates must be submitted with an IOCTL call to EPDSystem#MXCFB_SEND_UPDATE. In automatic mode, updates are generated by the driver when it detects that pages in a frame buffer memory region have been modified.

Automatic mode is available only when it has been enabled in the Linux kernel by the option CONFIG_FB_MXC_EINK_AUTO_UPDATE_MODE. You can find the configuration options used to build the kernel in a file under /proc or /boot, such as /proc/config.gz.

Parameters
mode:int

the automatic update mode, one of:

setPowerdownDelayback to summary
private void setPowerdownDelay(int delay)

Sets the delay between the completion of all updates in the driver and when the driver should power down the EPDC and display power supplies. To disable powering down entirely, use the delay value EPDSystem#FB_POWERDOWN_DISABLE.

Parameters
delay:int

the delay in milliseconds

setScreenInfoback to summary
private void setScreenInfo(EPDSystem.FbVarScreenInfo screen) throws IOException

Sets the variable screen information of the frame buffer.

"To ensure that the EPDC driver receives the initialization request, the activate field of the fb_var_screeninfo parameter should be set to FB_ACTIVATE_FORCE." [EPDC Panel Initialization, i.MX Linux Reference Manual]

To request a change to 8-bit grayscale format, the bits per pixel must be set to 8 and the grayscale value must be set to one of the two valid grayscale format values: GRAYSCALE_8BIT or GRAYSCALE_8BIT_INVERTED. [Grayscale Framebuffer Selection, i.MX Linux Reference Manual]

Parameters
screen:EPDSystem.FbVarScreenInfo

the object representing the variable screen information

Exceptions
IOException:
if an error occurs setting the information
setTemperatureback to summary
private void setTemperature(int temp)

Sets the temperature to be used by the EPDC driver in subsequent panel updates. Note that this temperature setting may be overridden by setting the temperature in a specific update to anything other than EPDSystem#TEMP_USE_AMBIENT.

Parameters
temp:int

the temperature in degrees Celsius

setUpdateSchemeback to summary
private void setUpdateScheme(int scheme)

Selects a scheme for the flow of updates within the driver.

Parameters
scheme:int

the update scheme, one of:

setWaveformModesback to summary
private void setWaveformModes(int init, int du, int gc4, int gc8, int gc16, int gc32)

Defines a mapping for common waveform modes. This mapping must be configured for the automatic waveform mode selection to function properly. Each of the parameters should be set to one of the following:

Implementation Note

This method fails on the Kobo Glo HD Model N437 with the error ENOTTY (25), "Inappropriate ioctl for device." The driver on that device uses an extended structure with four additional integers, changing its size and its corresponding request code. This method could use the extended structure, but the driver on the Kobo Glo HD ignores it and returns immediately, anyway. Furthermore, newer devices support both the current structure and the extended one, but define the extra fields in a different order. Therefore, simply use the current structure and ignore an error of ENOTTY, picking up the default values for any extra fields.

Parameters
init:int

the initialization mode for clearing the screen to all white

du:int

the direct update mode for changing any gray values to either all black or all white

gc4:int

the mode for 4-level (2-bit) grayscale images and text

gc8:int

the mode for 8-level (3-bit) grayscale images and text

gc16:int

the mode for 16-level (4-bit) grayscale images and text

gc32:int

the mode for 32-level (5-bit) grayscale images and text

syncback to summary
pack-priv void sync()

Sends the updated contents of the Linux frame buffer to the EPDC driver, optionally synchronizing with the driver by first waiting for the previous update to complete.

This method is not thread safe, but it is invoked only from the JavaFX Application Thread.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
waitForUpdateCompleteback to summary
private void waitForUpdateComplete(int marker)

Blocks and waits for a previous update request to complete.

Parameters
marker:int

the marker to identify a particular update, returned by sendUpdate(MxcfbUpdateData, int)