summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2020-12-03 11:31:24 +0200
committerTomi Valkeinen <tomi.valkeinen@ti.com>2020-12-03 11:31:24 +0200
commit764d6a0b7441796806a8fb8f10b79f009d5afb36 (patch)
tree56244ecfbe2acfbb21d1724591c23318e7173558
parent79b60742131540b4c30db9aa4342c513dee389a7 (diff)
crtc: add legacy gamma set
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
-rw-r--r--kms++/inc/kms++/crtc.h3
-rw-r--r--kms++/src/crtc.cpp18
-rw-r--r--py/pykms/pykmsbase.cpp4
3 files changed, 22 insertions, 3 deletions
diff --git a/kms++/inc/kms++/crtc.h b/kms++/inc/kms++/crtc.h
index 1ba8a07..cf64a86 100644
--- a/kms++/inc/kms++/crtc.h
+++ b/kms++/inc/kms++/crtc.h
@@ -39,7 +39,8 @@ public:
uint32_t height() const;
int mode_valid() const;
Videomode mode() const;
- int gamma_size() const;
+ int legacy_gamma_size() const;
+ void legacy_gamma_set(std::vector<std::tuple<uint16_t, uint16_t, uint16_t>> v);
private:
Crtc(Card& card, uint32_t id, uint32_t idx);
diff --git a/kms++/src/crtc.cpp b/kms++/src/crtc.cpp
index 6dc4333..1c1888f 100644
--- a/kms++/src/crtc.cpp
+++ b/kms++/src/crtc.cpp
@@ -173,9 +173,25 @@ Videomode Crtc::mode() const
return drm_mode_to_video_mode(m_priv->drm_crtc->mode);
}
-int Crtc::gamma_size() const
+int Crtc::legacy_gamma_size() const
{
return m_priv->drm_crtc->gamma_size;
}
+void Crtc::legacy_gamma_set(vector<tuple<uint16_t, uint16_t, uint16_t>> v)
+{
+ uint32_t len = v.size();
+ uint16_t red[len];
+ uint16_t green[len];
+ uint16_t blue[len];
+
+ for (uint32_t i = 0; i < len; ++i) {
+ red[i] = get<0>(v[i]);
+ green[i] = get<1>(v[i]);
+ blue[i] = get<2>(v[i]);
+ }
+
+ drmModeCrtcSetGamma(card().fd(), id(), len, red, green, blue);
+}
+
} // namespace kms
diff --git a/py/pykms/pykmsbase.cpp b/py/pykms/pykmsbase.cpp
index 43c2dfd..a963843 100644
--- a/py/pykms/pykmsbase.cpp
+++ b/py/pykms/pykmsbase.cpp
@@ -96,7 +96,9 @@ void init_pykmsbase(py::module& m)
.def_property_readonly("mode", &Crtc::mode)
.def_property_readonly("mode_valid", &Crtc::mode_valid)
.def("__repr__", [](const Crtc& o) { return "<pykms.Crtc " + to_string(o.id()) + ">"; })
- .def("refresh", &Crtc::refresh);
+ .def("refresh", &Crtc::refresh)
+ .def("legacy_gamma_size", &Crtc::legacy_gamma_size)
+ .def("legacy_gamma_set", &Crtc::legacy_gamma_set);
py::class_<Encoder, DrmPropObject, unique_ptr<Encoder, py::nodelete>>(m, "Encoder")
.def("refresh", &Encoder::refresh);