mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	libcamera: use the data type mask to select a type
In alloc_buffers we need to look at the data types mask. Select DmaBuf when not invalid and the DmaBuf flag is set, otherwise select memptr. See #1054
This commit is contained in:
		
							parent
							
								
									6e0ba50a9c
								
							
						
					
					
						commit
						cd79cdfb40
					
				
					 1 changed files with 14 additions and 4 deletions
				
			
		| 
						 | 
					@ -756,7 +756,19 @@ mmap_init(struct impl *this,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_log_info(this->log, "libcamera: In mmap_init()");
 | 
						spa_log_info(this->log, "libcamera: In mmap_init()");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (n_buffers > 0) {
 | 
				
			||||||
 | 
							d = buffers[0]->datas;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (d[0].type != SPA_ID_INVALID &&
 | 
				
			||||||
 | 
							    d[0].type & (1u << SPA_DATA_DmaBuf)) {
 | 
				
			||||||
			port->memtype = SPA_DATA_DmaBuf;
 | 
								port->memtype = SPA_DATA_DmaBuf;
 | 
				
			||||||
 | 
							} else if (d[0].type & (1u << SPA_DATA_MemPtr)) {
 | 
				
			||||||
 | 
								port->memtype = SPA_DATA_MemPtr;
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								spa_log_error(this->log, "v4l2: can't use buffers of type %d", d[0].type);
 | 
				
			||||||
 | 
								return -EINVAL;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* get n_buffers from libcamera */
 | 
						/* get n_buffers from libcamera */
 | 
				
			||||||
	uint32_t libcamera_nbuffers = libcamera_get_nbuffers(port->dev.camera);
 | 
						uint32_t libcamera_nbuffers = libcamera_get_nbuffers(port->dev.camera);
 | 
				
			||||||
| 
						 | 
					@ -778,7 +790,7 @@ mmap_init(struct impl *this,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		d = buffers[i]->datas;
 | 
							d = buffers[i]->datas;
 | 
				
			||||||
		for(j = 0; j < buffers[i]->n_datas; ++j) {
 | 
							for(j = 0; j < buffers[i]->n_datas; ++j) {
 | 
				
			||||||
			d[j].type = SPA_DATA_DmaBuf;
 | 
								d[j].type = port->memtype;
 | 
				
			||||||
			d[j].flags = SPA_DATA_FLAG_READABLE;
 | 
								d[j].flags = SPA_DATA_FLAG_READABLE;
 | 
				
			||||||
			d[j].mapoffset = 0;
 | 
								d[j].mapoffset = 0;
 | 
				
			||||||
			d[j].maxsize = libcamera_get_max_size(port->dev.camera);
 | 
								d[j].maxsize = libcamera_get_max_size(port->dev.camera);
 | 
				
			||||||
| 
						 | 
					@ -787,8 +799,6 @@ mmap_init(struct impl *this,
 | 
				
			||||||
			d[j].chunk->stride = port->fmt.bytesperline; /* FIXME:: This needs to be appropriately filled */
 | 
								d[j].chunk->stride = port->fmt.bytesperline; /* FIXME:: This needs to be appropriately filled */
 | 
				
			||||||
			d[j].chunk->flags = 0;
 | 
								d[j].chunk->flags = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			d[j].flags = SPA_DATA_FLAG_READABLE;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			if(port->memtype == SPA_DATA_DmaBuf) {
 | 
								if(port->memtype == SPA_DATA_DmaBuf) {
 | 
				
			||||||
				d[j].fd = libcamera_get_fd(port->dev.camera, i, j);
 | 
									d[j].fd = libcamera_get_fd(port->dev.camera, i, j);
 | 
				
			||||||
				spa_log_info(this->log, "libcamera: Got fd = %ld for buffer: #%d\n", d[j].fd, i);
 | 
									spa_log_info(this->log, "libcamera: Got fd = %ld for buffer: #%d\n", d[j].fd, i);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue