3131typedef struct snd_sof_ctl {
3232 struct plug_shm_glb_state * glb ;
3333 snd_ctl_ext_t ext ;
34- struct plug_mq_desc ipc_tx ;
35- struct plug_mq_desc ipc_rx ;
34+ struct plug_socket_desc ipc ;
3635 struct plug_shm_desc shm_ctx ;
3736 int subscribed ;
3837 int updated [MAX_CTLS ];
@@ -232,8 +231,7 @@ static int plug_ctl_read_integer(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, long
232231
233232 /* send the IPC message */
234233 memcpy (msg , & config , sizeof (config ));
235- err = plug_mq_cmd_tx_rx (& ctl -> ipc_tx , & ctl -> ipc_rx ,
236- msg , size , reply_data , reply_data_size );
234+ err = plug_ipc_cmd_tx_rx (& ctl -> ipc , msg , size , reply_data , reply_data_size );
237235 free (msg );
238236 if (err < 0 ) {
239237 SNDERR ("failed to set volume for control %s\n" , mixer_ctl -> hdr .name );
@@ -325,8 +323,7 @@ static int plug_ctl_write_integer(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, lon
325323 memcpy (msg + sizeof (config ), & volume , sizeof (volume ));
326324
327325 /* send the message and check status */
328- err = plug_mq_cmd_tx_rx (& ctl -> ipc_tx , & ctl -> ipc_rx ,
329- msg , size , & reply , sizeof (reply ));
326+ err = plug_ipc_cmd_tx_rx (& ctl -> ipc , msg , size , & reply , sizeof (reply ));
330327 free (msg );
331328 if (err < 0 ) {
332329 SNDERR ("failed to set volume control %s\n" , mixer_ctl -> hdr .name );
@@ -426,8 +423,7 @@ static int plug_ctl_read_enumerated(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key,
426423
427424 /* send the IPC message */
428425 memcpy (msg , & config , sizeof (config ));
429- err = plug_mq_cmd_tx_rx (& ctl -> ipc_tx , & ctl -> ipc_rx ,
430- msg , size , reply_data , reply_data_size );
426+ err = plug_ipc_cmd_tx_rx (& ctl -> ipc , msg , size , reply_data , reply_data_size );
431427 free (msg );
432428 if (err < 0 ) {
433429 SNDERR ("failed to get enum items for control %s\n" , enum_ctl -> hdr .name );
@@ -516,7 +512,7 @@ static int plug_ctl_write_enumerated(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key,
516512 free (data );
517513
518514 /* send the message and check status */
519- err = plug_mq_cmd_tx_rx (& ctl -> ipc_tx , & ctl -> ipc_rx , msg , msg_size , & reply , sizeof (reply ));
515+ err = plug_ipc_cmd_tx_rx (& ctl -> ipc , msg , msg_size , & reply , sizeof (reply ));
520516 free (msg );
521517 if (err < 0 ) {
522518 SNDERR ("failed to set enum control %s\n" , enum_ctl -> hdr .name );
@@ -573,8 +569,7 @@ static int plug_ctl_get_bytes_data(snd_sof_ctl_t *ctl, snd_ctl_ext_key_t key,
573569
574570 /* send the IPC message */
575571 memcpy (msg , & config , sizeof (config ));
576- err = plug_mq_cmd_tx_rx (& ctl -> ipc_tx , & ctl -> ipc_rx ,
577- msg , size , reply_data , reply_data_size );
572+ err = plug_ipc_cmd_tx_rx (& ctl -> ipc , msg , size , reply_data , reply_data_size );
578573 free (msg );
579574 if (err < 0 ) {
580575 SNDERR ("failed to get bytes data for control %s\n" , bytes_ctl -> hdr .name );
@@ -633,9 +628,8 @@ static int plug_ctl_write_bytes(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key,
633628 int err ;
634629
635630 /* send IPC with kcontrol data */
636- err = plug_send_bytes_data (& ctl -> ipc_tx , & ctl -> ipc_rx ,
637- ctl -> glb -> ctl [key ].module_id , ctl -> glb -> ctl [key ].instance_id ,
638- abi );
631+ err = plug_send_bytes_data (& ctl -> ipc , ctl -> glb -> ctl [key ].module_id ,
632+ ctl -> glb -> ctl [key ].instance_id , abi );
639633 if (err < 0 ) {
640634 SNDERR ("failed to set bytes data for control %s\n" , bytes_ctl -> hdr .name );
641635 return err ;
@@ -673,8 +667,7 @@ static int plug_tlv_rw(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, int op_flag,
673667 if (op_flag ) {
674668 int err ;
675669
676- err = plug_send_bytes_data (& ctl -> ipc_tx , & ctl -> ipc_rx ,
677- ctl -> glb -> ctl [key ].module_id ,
670+ err = plug_send_bytes_data (& ctl -> ipc , ctl -> glb -> ctl [key ].module_id ,
678671 ctl -> glb -> ctl [key ].instance_id , abi );
679672 if (err < 0 ) {
680673 SNDERR ("failed to set bytes data for control %s\n" , bytes_ctl -> hdr .name );
@@ -747,6 +740,7 @@ static void plug_ctl_close(snd_ctl_ext_t *ext)
747740 snd_sof_ctl_t * ctl = ext -> private_data ;
748741
749742 /* TODO: munmap */
743+ close (ctl -> ipc .socket_fd );
750744 free (ctl );
751745}
752746
@@ -793,34 +787,17 @@ SND_CTL_PLUGIN_DEFINE_FUNC(sof)
793787 goto error ;
794788 }
795789
796- /* init IPC tx message queue name */
797- err = plug_mq_init (& ctl -> ipc_tx , "sof" , "ipc-tx " , 0 );
790+ /* init IPC socket name */
791+ err = plug_socket_path_init (& ctl -> ipc , "sof" , "ipc" , 0 );
798792 if (err < 0 ) {
799793 SNDERR ("error: invalid name for IPC tx mq %s\n" , plug -> tplg_file );
800794 goto error ;
801795 }
802796
803- /* open the sof-pipe IPC tx message queue */
804- err = plug_mq_open (& ctl -> ipc_tx );
797+ err = plug_create_client_socket (& ctl -> ipc );
805798 if (err < 0 ) {
806- SNDERR ("error: failed to open sof-pipe IPC mq %s: %s" ,
807- ctl -> ipc_tx .queue_name , strerror (err ));
808- goto error ;
809- }
810-
811- /* init IPC rx message queue name */
812- err = plug_mq_init (& ctl -> ipc_rx , "sof" , "ipc-rx" , 0 );
813- if (err < 0 ) {
814- SNDERR ("error: invalid name for IPC rx mq %s\n" , plug -> tplg_file );
815- goto error ;
816- }
817-
818- /* open the sof-pipe IPC rx message queue */
819- err = plug_mq_open (& ctl -> ipc_rx );
820- if (err < 0 ) {
821- SNDERR ("error: failed to open sof-pipe IPC mq %s: %s" ,
822- ctl -> ipc_rx .queue_name , strerror (err ));
823- goto error ;
799+ SNDERR ("failed to connect to SOF pipe IPC socket : %s" , strerror (err ));
800+ return - errno ;
824801 }
825802
826803 /* create a SHM mapping for low latency stream position */
@@ -847,9 +824,6 @@ SND_CTL_PLUGIN_DEFINE_FUNC(sof)
847824 strncpy (ctl -> ext .mixername , "SOF" ,
848825 sizeof (ctl -> ext .mixername ) - 1 );
849826
850- /* polling on message queue - supported on Linux but not portable */
851- ctl -> ext .poll_fd = ctl -> ipc_tx .mq ;
852-
853827 ctl -> ext .callback = & sof_ext_callback ;
854828 ctl -> ext .private_data = ctl ;
855829 ctl -> ext .tlv .c = plug_tlv_rw ;
0 commit comments