#define MFC_FEATURE_SUPPORT(dev, f) ((f).support && ((dev)->fw.date >= (f).version))
+/* Low memory check */
+#define IS_LOW_MEM (totalram_pages <= ((SZ_1G + SZ_512M) >> PAGE_SHIFT))
+#define SZ_600M (6 * 1024 * 1024)
+
#endif /* __S5P_MFC_COMMON_H */
dev->pdata->support_10bit ? "supported" : "not supported",
dev->pdata->support_422 ? "supported" : "not supported",
dev->pdata->support_rgb ? "supported" : "not supported");
+ seq_printf(s, "[LOWMEM] is_low_mem: %d\n", IS_LOW_MEM);
if (dev->nal_q_handle)
seq_printf(s, "[NAL-Q] state: %d\n", dev->nal_q_handle->nal_q_state);
rectangle. */
s5p_mfc_dec_calc_dpb_size(ctx);
+ if (IS_LOW_MEM) {
+ unsigned int dpb_size;
+ /*
+ * If total memory requirement is too big for this device,
+ * then it returns error.
+ * DPB size : Total plane size * the number of DPBs
+ * 5: the number of extra DPBs
+ * 3: the number of DPBs for Android framework
+ * 600MB: being used to return an error,
+ * when 8K resolution video clip is being tried to be decoded
+ */
+ dpb_size = (ctx->raw_buf.total_plane_size * (ctx->dpb_count + 5 + 3));
+ if (dpb_size > SZ_600M) {
+ mfc_info_ctx("required memory size is too big (%dx%d, dpb: %d)\n",
+ ctx->img_width, ctx->img_height, ctx->dpb_count);
+ return -EINVAL;
+ }
+ }
+
pix_fmt_mp->width = ctx->img_width;
pix_fmt_mp->height = ctx->img_height;
pix_fmt_mp->num_planes = ctx->dst_fmt->mem_planes;