mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	v4l2: return a default format from G_FMT
This commit is contained in:
		
							parent
							
								
									73ad5d9057
								
							
						
					
					
						commit
						5a262b4bd3
					
				
					 1 changed files with 31 additions and 2 deletions
				
			
		| 
						 | 
					@ -1466,11 +1466,40 @@ static int vidioc_enum_fmt(struct file *file, struct v4l2_fmtdesc *arg)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int vidioc_g_fmt(struct file *file, struct v4l2_format *arg)
 | 
					static int vidioc_g_fmt(struct file *file, struct v4l2_format *arg)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						struct param *p;
 | 
				
			||||||
 | 
						struct global *g = file->node;
 | 
				
			||||||
 | 
						int res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (arg->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
 | 
						if (arg->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
 | 
				
			||||||
		return -EINVAL;
 | 
							return -EINVAL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						pw_thread_loop_lock(file->loop);
 | 
				
			||||||
 | 
						if (file->v4l2_format.fmt.pix.pixelformat != 0) {
 | 
				
			||||||
		*arg = file->v4l2_format;
 | 
							*arg = file->v4l2_format;
 | 
				
			||||||
	return 0;
 | 
						} else {
 | 
				
			||||||
 | 
							struct v4l2_format tmp;
 | 
				
			||||||
 | 
							bool found = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							spa_list_for_each(p, &g->param_list, link) {
 | 
				
			||||||
 | 
								if (p->id != SPA_PARAM_EnumFormat || p->param == NULL)
 | 
				
			||||||
 | 
									continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if (param_to_fmt(p->param, &tmp) < 0)
 | 
				
			||||||
 | 
									continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								found = true;
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							if (!found) {
 | 
				
			||||||
 | 
								res = -EINVAL;
 | 
				
			||||||
 | 
								goto exit_unlock;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							*arg = file->v4l2_format = tmp;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						res = 0;
 | 
				
			||||||
 | 
					exit_unlock:
 | 
				
			||||||
 | 
						pw_thread_loop_unlock(file->loop);
 | 
				
			||||||
 | 
						return res;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int score_diff(struct v4l2_format *fmt, struct v4l2_format *tmp)
 | 
					static int score_diff(struct v4l2_format *fmt, struct v4l2_format *tmp)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue