summaryrefslogtreecommitdiff
path: root/linux-core/nv04_mc.c
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2008-07-23 10:07:16 -0700
committerEric Anholt <eric@anholt.net>2008-07-23 10:10:54 -0700
commit439d7106832f2e9742deb900d96f1d3bc07162b1 (patch)
treef016507c4003135279ac53cb8c5521217306c8a0 /linux-core/nv04_mc.c
parentbddb952578d58c4dcfafe969c045a39d27666b56 (diff)
intel-gem: Add a quick hack to reduce clflushing on pread.
This increases overhead for the large-readpixels case due to the repeated page cache accessing, but greatly reduces overhead for the small-readpixels case.
Diffstat (limited to 'linux-core/nv04_mc.c')
0 files changed, 0 insertions, 0 deletions
ef='#n106'>106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
#!/usr/bin/python3

import sys
import selectors
import pykms
import argparse
import time

iw = 640
ih = 480
ifmt = pykms.PixelFormat.XRGB8888

ow = 640
oh = 480
ofmt = pykms.PixelFormat.XRGB8888

card = pykms.Card()
res = pykms.ResourceManager(card)
conn = res.reserve_connector()
crtc = res.reserve_crtc(conn)
plane1 = res.reserve_overlay_plane(crtc, ifmt)
plane2 = res.reserve_overlay_plane(crtc, ofmt)

print("{}, {}".format(plane1.id, plane2.id))

mode = conn.get_default_mode()
modeb = mode.to_blob(card)

card.disable_planes()

req = pykms.AtomicReq(card)
req.add(conn, "CRTC_ID", crtc.id)
req.add(crtc, {"ACTIVE": 1,
		"MODE_ID": modeb.id})
req.commit_sync(allow_modeset = True)

NUM_BUFS = 4

src_fbs = []
dst_fbs = []

for i in range(NUM_BUFS):
	fb = pykms.DumbFramebuffer(card, iw, ih, ifmt)
	pykms.draw_test_pattern(fb);
	pykms.draw_text(fb, iw // 2, 2, str(i), pykms.white);
	src_fbs.append(fb)

	fb = pykms.DumbFramebuffer(card, ow, oh, ofmt)
	dst_fbs.append(fb)

# put the planes on the screen, so that WB doesn't take them
req = pykms.AtomicReq(card)
req.add_plane(plane1, src_fbs[0], crtc, dst=(0, 0, 400, 480))
req.add_plane(plane2, dst_fbs[1], crtc, dst=(400, 0, 400, 480))
r = req.commit_sync(allow_modeset = True)
assert r == 0

vid = pykms.VideoDevice("/dev/video10")

src_streamer = vid.output_streamer
dst_streamer = vid.capture_streamer

src_streamer.set_format(ifmt, iw, ih)
(left, top, width, height) = src_streamer.get_selection()
print("get: crop -> {},{}-{}x{}".format(left, top, width, height))
(left, top, width, height) = src_streamer.set_selection(160, 0, 320, 240)
print("set: crop -> {},{}-{}x{}".format(left, top, width, height))

dst_streamer.set_format(ofmt, ow, oh)