kmssink: Hard code scale ratio for qxp
For qxp, we can not use setplane to try scale ratio.
Its upscale has no limitation. Add platform detect
code and hard code scale ratio for qxp
upstream status: i.MX specific
diff --git a/sys/kms/gstkmssink.c b/sys/kms/gstkmssink.c
index 40c465e..3264201 100644
--- a/sys/kms/gstkmssink.c
+++ b/sys/kms/gstkmssink.c
@@ -102,6 +102,8 @@
static GParamSpec *g_properties[PROP_N] = { NULL, };
+#define SCALE_RATIO_NO_LIMITATION 100000
+
static void
gst_kms_sink_set_render_rectangle (GstVideoOverlay * overlay,
gint x, gint y, gint width, gint height)
@@ -465,6 +467,15 @@
if (self->conn_id < 0 || !self->display_connected)
return;
+ /* FIXME: for dpu, we can only hard code the scale ratio,
+ * dpu has no limitation when do upscale but can not support
+ * downscale */
+ if (strcmp (get_imx_drm_device_name(), "DPU") == 0) {
+ self->downscale_ratio = 1;
+ self->upscale_ratio = SCALE_RATIO_NO_LIMITATION;
+ return;
+ }
+
gst_video_info_init (&vinfo);
gst_video_info_set_format (&vinfo, GST_VIDEO_FORMAT_NV12, self->hdisplay, self->vdisplay);
@@ -1828,14 +1839,14 @@
if ((result.x + result.w) > self->hdisplay) {
gint crop_width = self->hdisplay - result.x;
if (crop_width > 0)
- src.w = crop_width * src.w / result.w;
+ src.w = GST_ROUND_UP_2 (crop_width * src.w / result.w);
result.w = crop_width;
}
if ((result.y + result.h) > self->vdisplay) {
gint crop_height = self->vdisplay - result.y;
if (crop_height > 0)
- src.h = crop_height * src.h / result.h;
+ src.h = GST_ROUND_UP_2 (crop_height * src.h / result.h);
result.h = crop_height;
}
diff --git a/sys/kms/gstkmsutils.c b/sys/kms/gstkmsutils.c
index 4be7137..23b3cc7 100644
--- a/sys/kms/gstkmsutils.c
+++ b/sys/kms/gstkmsutils.c
@@ -28,6 +28,8 @@
#endif
#include <drm_fourcc.h>
+#include <dirent.h>
+#include <string.h>
#include "gstkmsutils.h"
@@ -231,3 +233,38 @@
if (dpy_par_d)
*dpy_par_d = device_par_map[index][windex ^ 1];
}
+
+const gchar *
+get_imx_drm_device_name (void)
+{
+ struct dirent **entry_list;
+ guint count;
+ guint i;
+ const gchar * device;
+
+ count = scandir ("/proc/device-tree", &entry_list, 0, alphasort);
+ if (count < 0)
+ return NULL;
+
+ for (i = 0; i < count; i++) {
+ struct dirent *entry;
+
+ entry = entry_list[i];
+ if (strstr (entry->d_name, "dpu@")) {
+ device = "DPU";
+ break;
+ }
+
+ if (strstr (entry->d_name, "dcss@")) {
+ device = "DCSS";
+ break;
+ }
+ }
+
+ for (i = 0; i < count; i++) {
+ g_free (entry_list[i]);
+ }
+ g_free (entry_list);
+
+ return device;
+}
diff --git a/sys/kms/gstkmsutils.h b/sys/kms/gstkmsutils.h
index 6570070..95e81f8 100644
--- a/sys/kms/gstkmsutils.h
+++ b/sys/kms/gstkmsutils.h
@@ -41,7 +41,7 @@
guint dev_height_mm,
guint * dpy_par_n,
guint * dpy_par_d);
-
+const gchar * get_imx_drm_device_name (void);
G_END_DECLS
#endif