pr_info("     buf_init: %u buf_cleanup: %u buf_prepare: %u buf_finish: %u\n",
                                vb->cnt_buf_init, vb->cnt_buf_cleanup,
                                vb->cnt_buf_prepare, vb->cnt_buf_finish);
-                       pr_info("     buf_queue: %u buf_done: %u buf_request_complete: %u\n",
-                               vb->cnt_buf_queue, vb->cnt_buf_done,
-                               vb->cnt_buf_request_complete);
+                       pr_info("     buf_out_validate: %u buf_queue: %u buf_done: %u buf_request_complete: %u\n",
+                               vb->cnt_buf_out_validate, vb->cnt_buf_queue,
+                               vb->cnt_buf_done, vb->cnt_buf_request_complete);
                        pr_info("     alloc: %u put: %u prepare: %u finish: %u mmap: %u\n",
                                vb->cnt_mem_alloc, vb->cnt_mem_put,
                                vb->cnt_mem_prepare, vb->cnt_mem_finish,
                return 0;
        WARN_ON(vb->synced);
 
+       if (q->is_output) {
+               ret = call_vb_qop(vb, buf_out_validate, vb);
+               if (ret) {
+                       dprintk(1, "buffer validation failed\n");
+                       return ret;
+               }
+       }
+
        vb->state = VB2_BUF_STATE_PREPARING;
 
        switch (q->memory) {
                        return -EINVAL;
                }
 
+               if (q->is_output && !vb->prepared) {
+                       ret = call_vb_qop(vb, buf_out_validate, vb);
+                       if (ret) {
+                               dprintk(1, "buffer validation failed\n");
+                               return ret;
+                       }
+               }
+
                media_request_object_init(&vb->req_obj);
 
                /* Make sure the request is in a safe state for updating. */
 
        u32             cnt_mem_num_users;
        u32             cnt_mem_mmap;
 
+       u32             cnt_buf_out_validate;
        u32             cnt_buf_init;
        u32             cnt_buf_prepare;
        u32             cnt_buf_finish;
  * @wait_finish:       reacquire all locks released in the previous callback;
  *                     required to continue operation after sleeping while
  *                     waiting for a new buffer to arrive.
+ * @buf_out_validate:  called when the output buffer is prepared or queued
+ *                     to a request; drivers can use this to validate
+ *                     userspace-provided information; optional.
  * @buf_init:          called once after allocating a buffer (in MMAP case)
  *                     or after acquiring a new USERPTR buffer; drivers may
  *                     perform additional buffer-related initialization;
        void (*wait_prepare)(struct vb2_queue *q);
        void (*wait_finish)(struct vb2_queue *q);
 
+       int (*buf_out_validate)(struct vb2_buffer *vb);
        int (*buf_init)(struct vb2_buffer *vb);
        int (*buf_prepare)(struct vb2_buffer *vb);
        void (*buf_finish)(struct vb2_buffer *vb);