py: add set_prop()
authorTomi Valkeinen <tomi.valkeinen@ti.com>
Thu, 26 May 2016 11:12:15 +0000 (14:12 +0300)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Thu, 26 May 2016 11:12:15 +0000 (14:12 +0300)
py/gamma.py
py/helpers.py

index c8da18fcb1af665a693349b493245e30529c4467..7ecd19de1212f541f9fc412ff0629dedf03f0b33 100644 (file)
@@ -32,14 +32,10 @@ for i in range(256):
 
 gamma = pykms.Blob(card, arr);
 
-set_props(crtc, {
-    "GAMMA_LUT": gamma.id,
-})
+set_prop(crtc, "GAMMA_LUT", gamma.id)
 
 input("press enter to remove gamma\n")
 
-set_props(crtc, {
-    "GAMMA_LUT": 0,
-})
+set_prop(crtc, "GAMMA_LUT", 0)
 
 input("press enter to exit\n")
index 456efcd83343fb8c420c5fb2e71c3bd80570071c..fd67d4160cb9214d77c9a8e43db0a392b0f879d2 100644 (file)
@@ -11,6 +11,16 @@ def props(o):
         prop = o.card.get_prop(propid)
         print("%-15s %d (%#x)" % (prop.name, propval, propval))
 
+def set_prop(ob, prop, value):
+    if ob.card.has_atomic:
+        areq = pykms.AtomicReq(ob.card)
+        areq.add(ob, prop, value)
+        if areq.commit_sync() != 0:
+            print("commit failed")
+    else:
+        if ob.set_prop_value(prop, value) != 0:
+            print("setting property failed")
+
 def set_props(ob, map):
     if ob.card.has_atomic:
         areq = pykms.AtomicReq(ob.card)