summaryrefslogtreecommitdiff
path: root/tests/setversion.c
AgeCommit message (Expand)Author
2009-04-06Skip tests that require rootKristian Høgsberg
2007-08-15Require master in setversion test, since it requires auth.Eric Anholt
2007-08-15Add a regression test for the setversion interface.Eric Anholt
2 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
#include <xf86drm.h>
#include <xf86drmMode.h>

#include <kms++/kms++.h>

using namespace std;

namespace kms
{

Blob::Blob(Card& card, uint32_t blob_id)
	: DrmObject(card, blob_id, DRM_MODE_OBJECT_BLOB), m_created(false)
{
	// XXX should we verify that the blob_id is a blob object?
}

Blob::Blob(Card& card, void* data, size_t len)
	: DrmObject(card, DRM_MODE_OBJECT_BLOB), m_created(true)
{
	uint32_t id;

	int r = drmModeCreatePropertyBlob(card.fd(), data, len, &id);
	if (r)
		throw invalid_argument("FAILED TO CREATE PROP\n");

	set_id(id);
}

Blob::~Blob()
{
	if (m_created)
		drmModeDestroyPropertyBlob(card().fd(), id());
}

vector<uint8_t> Blob::data()
{
	drmModePropertyBlobPtr blob = drmModeGetPropertyBlob(card().fd(), id());

	if (!blob)
		throw invalid_argument("Blob data not available");

	uint8_t* data = (uint8_t*)blob->data;

	auto v = vector<uint8_t>(data, data + blob->length);

	drmModeFreePropertyBlob(blob);

	return v;
}

}