drivers: video: altair: nxstyle fixes

Nxstyle fixes to pass CI

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
This commit is contained in:
Alin Jerpelea 2021-01-26 09:14:35 +01:00 committed by Xiang Xiao
parent bdb4b344a8
commit cb5d8b53cb
4 changed files with 851 additions and 215 deletions

View File

@ -34,16 +34,17 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
*****************************************************************************/ ****************************************************************************/
/***************************************************************************** /****************************************************************************
* Theory of Operation * Theory of Operation
* *
* The MAX7456 is a single-channel, monochrome, on-screen-display generator * The MAX7456 is a single-channel, monochrome, on-screen-display generator
* that accepts an NTSC or PAL video input signal, overlays user-defined * that accepts an NTSC or PAL video input signal, overlays user-defined
* character data, and renders the combined stream to CVBS (analog) output. * character data, and renders the combined stream to CVBS (analog) output.
* The typical use case then forwards that CVBS output to a video transmitter, * The typical use case then forwards that CVBS output to a video
* analog display, recording device, and/or other external components. * transmitter, analog display, recording device, and/or other external
* components.
* *
* The chip is fundamentally an SPI slave device with a register bank to * The chip is fundamentally an SPI slave device with a register bank to
* configure the chip's analog components, update values in the display frame * configure the chip's analog components, update values in the display frame
@ -72,8 +73,8 @@
* *
* Note: Although we use the term "frame buffer", we cannot use the NuttX * Note: Although we use the term "frame buffer", we cannot use the NuttX
* standard /dev/fbN interface because our buffer memory is accessible only * standard /dev/fbN interface because our buffer memory is accessible only
* across SPI. This is an inexpensive, slow, simple chip, and you wouldn't use * across SPI. This is an inexpensive, slow, simple chip, and you wouldn't
* it for intensive work, but you WOULD use it on a memory-constrained * use it for intensive work, but you WOULD use it on a memory-constrained
* device. We keep our RAM footprint small by not keeping a local copy of the * device. We keep our RAM footprint small by not keeping a local copy of the
* framebuffer data. * framebuffer data.
* *
@ -439,10 +440,10 @@ static int regaddr_from_name(FAR const char *name)
* *
* Description: * Description:
* Reads @len bytes into @buf from @dev, starting at register address * Reads @len bytes into @buf from @dev, starting at register address
* @addr. This is a low-level function used for reading a sequence of one or * @addr. This is a low-level function used for reading a sequence of one
* more register values, and isn't usually called directly unless you REALLY * or more register values, and isn't usually called directly unless you
* know what you are doing. Consider one of the register-specific helper * REALLY know what you are doing. Consider one of the register-specific
* functions defined below whenever possible. * helper functions defined below whenever possible.
* *
* Note: The caller must hold @dev->lock before calling this function. * Note: The caller must hold @dev->lock before calling this function.
* *
@ -505,8 +506,8 @@ static int __mx7_read_reg(FAR struct mx7_dev_s *dev,
* Writes @len bytes from @buf to @dev, starting at @addr. This is a * Writes @len bytes from @buf to @dev, starting at @addr. This is a
* low-level function used for updating a sequence of one or more register * low-level function used for updating a sequence of one or more register
* values, and it DOES NOT check that the register being requested is * values, and it DOES NOT check that the register being requested is
* write-capable. This function isn't called directly unless you REALLY know * write-capable. This function isn't called directly unless you REALLY
* what you are doing. * know what you are doing.
* *
* Consider one of the register-specific helper functions defined below * Consider one of the register-specific helper functions defined below
* whenever possible. If a helper function for the register you desire to * whenever possible. If a helper function for the register you desire to
@ -628,7 +629,8 @@ static inline int __mx7_read_reg__dmm(FAR struct mx7_dev_s *dev)
* *
****************************************************************************/ ****************************************************************************/
static inline int __mx7_write_reg__vm0(FAR struct mx7_dev_s *dev, uint8_t val) static inline int __mx7_write_reg__vm0(FAR struct mx7_dev_s *dev,
uint8_t val)
{ {
return __mx7_write_reg(dev, VM0, &val, sizeof(val)); return __mx7_write_reg(dev, VM0, &val, sizeof(val));
} }
@ -687,7 +689,8 @@ static inline int __mx7_write_reg__cmah(FAR struct mx7_dev_s *dev,
* *
****************************************************************************/ ****************************************************************************/
static inline int __mx7_write_reg__cmm(FAR struct mx7_dev_s *dev, uint8_t val) static inline int __mx7_write_reg__cmm(FAR struct mx7_dev_s *dev,
uint8_t val)
{ {
return __mx7_write_reg(dev, CMM, &val, sizeof(val)); return __mx7_write_reg(dev, CMM, &val, sizeof(val));
} }
@ -789,7 +792,8 @@ static inline int __mx7_read_reg__cmdo(FAR struct mx7_dev_s *dev)
* *
****************************************************************************/ ****************************************************************************/
static inline int __mx7_write_reg__dmm(FAR struct mx7_dev_s *dev, uint8_t val) static inline int __mx7_write_reg__dmm(FAR struct mx7_dev_s *dev,
uint8_t val)
{ {
return __mx7_write_reg(dev, DMM, &val, sizeof(val)); return __mx7_write_reg(dev, DMM, &val, sizeof(val));
} }
@ -966,7 +970,7 @@ static void mx7_reset(FAR struct mx7_dev_s *dev)
__unlock(dev); __unlock(dev);
} }
/************************************************************************ /****************************************************************************
* Name: __write_fb * Name: __write_fb
* *
* Description: * Description:
@ -1143,7 +1147,8 @@ static ssize_t __write_fb(FAR struct mx7_dev_s *dev,
* Each row in the CA EEPROM is 64 bytes wide, but only the first 54 bytes * Each row in the CA EEPROM is 64 bytes wide, but only the first 54 bytes
* are used. The rest are marked as "unused memory" in the datasheet. All * are used. The rest are marked as "unused memory" in the datasheet. All
* 64 bytes of each row are included in the data we return, if the user's * 64 bytes of each row are included in the data we return, if the user's
* request spans that area. We assume that the user understands the format. * request spans that area. We assume that the user understands the
* format.
* *
* In total, the chip has 64 bytes per row x 256 rows of EEPROM. * In total, the chip has 64 bytes per row x 256 rows of EEPROM.
* *
@ -1241,6 +1246,7 @@ static ssize_t __read_cm(FAR struct mx7_dev_s *dev,
/* The shadow RAM is large enough to hold an entire row, so we don't /* The shadow RAM is large enough to hold an entire row, so we don't
* need to go back for another until we've read all of this one. * need to go back for another until we've read all of this one.
*/ */
do do
{ {
__mx7_write_reg__cmal(dev, cmal); __mx7_write_reg__cmal(dev, cmal);
@ -1424,14 +1430,14 @@ static ssize_t mx7_write_fb(FAR struct file *filep, FAR const char *buf,
* *
* We use the approach you see here so that we don't have to have one * We use the approach you see here so that we don't have to have one
* distinct function (and a separate file_operations structure) for each of * distinct function (and a separate file_operations structure) for each of
* the many interfaces we're likely to create for interacting with this chip * the many interfaces we're likely to create for interacting with this
* in its various useful ways. This schema also lets us re-use the interface * chip in its various useful ways. This schema also lets us re-use the
* code internally (see the test-pattern generator at startup.) * interface code internally (see the test-pattern generator at startup.)
* *
* In general, any function we call from here uses the combination of seek() * In general, any function we call from here uses the combination of
* and write() to implement a zero-copy frame buffer. The seek() parameter * seek() and write() to implement a zero-copy frame buffer. The seek()
* sets the current cursor position, and successive write()s provide the * parameter sets the current cursor position, and successive write()s
* character data starting at that position. * provide the character data starting at that position.
* *
* TODO: At the moment, we have no mechanism for setting the character * TODO: At the moment, we have no mechanism for setting the character
* attribute (the LBC, BLK, and INV fields in DMM) for the data arriving * attribute (the LBC, BLK, and INV fields in DMM) for the data arriving
@ -1439,9 +1445,9 @@ static ssize_t mx7_write_fb(FAR struct file *filep, FAR const char *buf,
* for the basic stuff. * for the basic stuff.
* *
* The above isn't a hard problem to solve, I just don't need to solve it * The above isn't a hard problem to solve, I just don't need to solve it
* right now. And, I don't know what the most convenient solution would look * right now. And, I don't know what the most convenient solution would
* like: the obvious choice is ioctl(), but I don't like ioctl() because I * look like: the obvious choice is ioctl(), but I don't like ioctl()
* can't test it from the command line. * because I can't test it from the command line.
* *
* One idea is to have "fb", "blink", "inv", and other entry points for * One idea is to have "fb", "blink", "inv", and other entry points for
* writing data with specific attributes. That has a nice feel to it, * writing data with specific attributes. That has a nice feel to it,
@ -1598,18 +1604,18 @@ static int mx7_debug_close(FAR struct file *filep)
* "/dev/osd0/VM0", etc., and reads from all of those interfaces arrive * "/dev/osd0/VM0", etc., and reads from all of those interfaces arrive
* here. * here.
* *
* Utilities like cat(1) will exit automatically at EOF, which can be tricky * Utilities like cat(1) will exit automatically at EOF, which can be
* to deliver at the right time. We achieve this by reading the associated * tricky to deliver at the right time. We achieve this by reading the
* register value only once, when filep->f_pos is at the beginning of the * associated register value only once, when filep->f_pos is at the
* "file" we're emulating. The value obtained is stored in dev->debug[], and * beginning of the "file" we're emulating. The value obtained is stored
* we work our way through that and increment the "file position" * in dev->debug[], and we work our way through that and increment the
* accordingly to keep track (because the user may ask for only one byte * "file position" accordingly to keep track (because the user may ask for
* at a time, and our register values require two bytes to express as * only one byte at a time, and our register values require two bytes to
* ascii-hex text). * express as ascii-hex text).
* *
* When we reach the end of dev->debug[], we return EOF. If the user wants a * When we reach the end of dev->debug[], we return EOF. If the user wants
* fresh copy, they can either close and reopen the interface, or move the * a fresh copy, they can either close and reopen the interface, or move
* file pointer back to 0 via a seek operation. * the file pointer back to 0 via a seek operation.
* *
****************************************************************************/ ****************************************************************************/

File diff suppressed because it is too large Load Diff

View File

@ -33,6 +33,7 @@
/**************************************************************************** /****************************************************************************
* Private Functions * Private Functions
****************************************************************************/ ****************************************************************************/
static void init_buf_chain(video_framebuff_t *fbuf) static void init_buf_chain(video_framebuff_t *fbuf)
{ {
int i; int i;
@ -83,14 +84,17 @@ static inline vbuf_container_t *dequeue_vbuf_unsafe(video_framebuff_t *fbuf)
{ {
fbuf->vbuf_tail->next = fbuf->vbuf_top->next; fbuf->vbuf_tail->next = fbuf->vbuf_top->next;
} }
fbuf->vbuf_top = fbuf->vbuf_top->next; fbuf->vbuf_top = fbuf->vbuf_top->next;
} }
return ret; return ret;
} }
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
void video_framebuff_init(video_framebuff_t *fbuf) void video_framebuff_init(video_framebuff_t *fbuf)
{ {
fbuf->mode = V4L2_BUF_MODE_RING; fbuf->mode = V4L2_BUF_MODE_RING;
@ -117,25 +121,28 @@ int video_framebuff_realloc_container(video_framebuff_t *fbuf, int sz)
if (fbuf->vbuf_alloced == NULL || fbuf->container_size != sz) if (fbuf->vbuf_alloced == NULL || fbuf->container_size != sz)
{ {
if (fbuf->container_size != sz) if (fbuf->container_size != sz)
{ {
if (fbuf->vbuf_alloced != NULL) if (fbuf->vbuf_alloced != NULL)
{ {
kmm_free(fbuf->vbuf_alloced); kmm_free(fbuf->vbuf_alloced);
} }
fbuf->vbuf_alloced = NULL;
fbuf->container_size = 0; fbuf->vbuf_alloced = NULL;
} fbuf->container_size = 0;
if (sz > 0) }
{
fbuf->vbuf_alloced if (sz > 0)
= (vbuf_container_t *)kmm_malloc(sizeof(vbuf_container_t)*sz); {
if (fbuf->vbuf_alloced == NULL) fbuf->vbuf_alloced
{ = (vbuf_container_t *)kmm_malloc(sizeof(vbuf_container_t)*sz);
return -ENOMEM; if (fbuf->vbuf_alloced == NULL)
} {
} return -ENOMEM;
fbuf->container_size = sz; }
}
fbuf->container_size = sz;
} }
cleanup_container(fbuf); cleanup_container(fbuf);
@ -154,6 +161,7 @@ vbuf_container_t *video_framebuff_get_container(video_framebuff_t *fbuf)
fbuf->vbuf_empty = ret->next; fbuf->vbuf_empty = ret->next;
ret->next = NULL; ret->next = NULL;
} }
nxsem_post(&fbuf->lock_empty); nxsem_post(&fbuf->lock_empty);
return ret; return ret;
@ -197,6 +205,7 @@ void video_framebuff_queue_container(video_framebuff_t *fbuf,
{ {
fbuf->vbuf_tail->next = NULL; fbuf->vbuf_tail->next = NULL;
} }
leave_critical_section(flags); leave_critical_section(flags);
} }
@ -210,6 +219,7 @@ vbuf_container_t *video_framebuff_dq_valid_container(video_framebuff_t *fbuf)
{ {
ret = dequeue_vbuf_unsafe(fbuf); ret = dequeue_vbuf_unsafe(fbuf);
} }
leave_critical_section(flags); leave_critical_section(flags);
return ret; return ret;
@ -262,8 +272,10 @@ void video_framebuff_change_mode(video_framebuff_t *fbuf,
fbuf->vbuf_next_dma = fbuf->vbuf_top; fbuf->vbuf_next_dma = fbuf->vbuf_top;
} }
} }
fbuf->mode = mode; fbuf->mode = mode;
} }
leave_critical_section(flags); leave_critical_section(flags);
} }

View File

@ -21,12 +21,20 @@
#ifndef __VIDEO_VIDEO_FRAMEBUFF_H__ #ifndef __VIDEO_VIDEO_FRAMEBUFF_H__
#define __VIDEO_VIDEO_FRAMEBUFF_H__ #define __VIDEO_VIDEO_FRAMEBUFF_H__
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/video/video.h> #include <nuttx/video/video.h>
#include <nuttx/semaphore.h> #include <nuttx/semaphore.h>
/****************************************************************************
* Public Functions Definistions
****************************************************************************/
struct vbuf_container_s struct vbuf_container_s
{ {
struct v4l2_buffer buf; /* Buffer information */ struct v4l2_buffer buf; /* Buffer information */
struct vbuf_container_s *next; /* pointer to next buffer */ struct vbuf_container_s *next; /* pointer to next buffer */
}; };